Function ntex::web::service [−][src]
pub fn service<T: IntoPattern>(path: T) -> WebServiceAdapter
Expand description
Create service adapter for a specific path.
use ntex::web::{self, guard, App, HttpResponse, Error, DefaultError};
async fn my_service(req: web::WebRequest<DefaultError>) -> Result<web::WebResponse, Error> {
Ok(req.into_response(HttpResponse::Ok().finish()))
}
let app = App::new().service(
web::service("/users/*")
.guard(guard::Header("content-type", "text/plain"))
.finish(my_service)
);