[][src]Function actix_web::web::service

pub fn service<T: IntoPattern>(path: T) -> WebService

Create raw service for a specific path.

use actix_web::{dev, web, guard, App, Error, HttpResponse};

async fn my_service(req: dev::ServiceRequest) -> Result<dev::ServiceResponse, 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)
);