Struct actix_web::dev::WebService [−][src]
pub struct WebService { /* fields omitted */ }
Implementations
Create new WebService
instance.
Add match guard to a web service.
use actix_web::{web, guard, dev, App, Error, HttpResponse};
async fn index(req: dev::ServiceRequest) -> Result<dev::ServiceResponse, Error> {
Ok(req.into_response(HttpResponse::Ok().finish()))
}
fn main() {
let app = App::new()
.service(
web::service("/app")
.guard(guard::Header("content-type", "text/plain"))
.finish(index)
);
}
pub fn finish<T, F>(self, service: F) -> impl HttpServiceFactory where
F: IntoServiceFactory<T, ServiceRequest>,
T: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error, InitError = ()> + 'static,
pub fn finish<T, F>(self, service: F) -> impl HttpServiceFactory where
F: IntoServiceFactory<T, ServiceRequest>,
T: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error, InitError = ()> + 'static,
Set a service factory implementation and generate web service.