-
ContextRoute configuration of a service The route configuration is implemented in a function which takes the The simple example below trigger the error. Exampleuse actix_web::{http::Method, middleware, web, App, HttpResponse, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(web::resource("/health-check").route(web::get().to(HttpResponse::Ok)))
.service(api_service(12))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
fn api_service(arg_from_clap: i64) -> actix_web::Scope {
actix_web::Scope::new("/api")
.wrap(middleware::DefaultHeaders::new().add(("X-Version", "0.2"))) // Example compile if this line is removed
.service(
web::resource("/test")
.route(web::get().to(HttpResponse::Ok))
.route(web::method(Method::HEAD).to(HttpResponse::MethodNotAllowed)),
)
} Compiler error
Versionactix-web = 4 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To change the default type parameter for
|
Beta Was this translation helpful? Give feedback.
To change the default type parameter for
Scope
s: