我想把我的应用程序路由分组在范围内,这样我将来可以根据域名分离它们的文件位置。
我尝试做的是转换。
HttpServer::new(move || App::new().app_data(app_state.clone()).service(delete_comment).service(update_comment).service(get_comments).service(create_comment))
.bind(("127.0.0.1", 8080))?
.run()
.await
至:
let comment_scope = web::scope("/comments").service(delete_comment).service(update_comment).service(get_comments).service(create_comment);
HttpServer::new(move || App::new().app_data(app_state.clone()).service(comment_scope))
.bind(("127.0.0.1", 8080))?
.run()
.await
但它一直告诉我 Clone
特性未实现于 actix_web::Scope
。我该如何修复这个问题?
.bind
替换为.listen
与配置路由有什么关系? - undefined