Struct actix_web::dev::WebService
source · pub struct WebService { /* private fields */ }Implementations§
source§impl WebService
impl WebService
sourcepub fn new<T: IntoPatterns>(path: T) -> Self
pub fn new<T: IntoPatterns>(path: T) -> Self
Create new WebService instance.
sourcepub fn guard<G: Guard + 'static>(self, guard: G) -> Self
pub fn guard<G: Guard + 'static>(self, guard: G) -> Self
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()))
}
let app = App::new()
.service(
web::service("/app")
.guard(guard::Header("content-type", "text/plain"))
.finish(index)
);sourcepub fn finish<T, F>(self, service: F) -> impl HttpServiceFactorywhere
F: IntoServiceFactory<T, ServiceRequest>,
T: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error, InitError = ()> + 'static,
pub fn finish<T, F>(self, service: F) -> impl HttpServiceFactorywhere
F: IntoServiceFactory<T, ServiceRequest>,
T: ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse, Error = Error, InitError = ()> + 'static,
Set a service factory implementation and generate web service.