Function actix_web::web::service

source ·
pub fn service<T: IntoPatterns>(path: T) -> WebService
Expand description

Creates a 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)
);