pub struct WebService { /* private fields */ }
Implementations§
Source§impl WebService
impl WebService
Sourcepub fn new<T>(path: T) -> WebServicewhere
T: IntoPatterns,
pub fn new<T>(path: T) -> WebServicewhere
T: IntoPatterns,
Create new WebService
instance.
Sourcepub fn name(self, name: &str) -> WebService
pub fn name(self, name: &str) -> WebService
Set service name.
Name is used for URL generation.
Sourcepub fn guard<G>(self, guard: G) -> WebServicewhere
G: Guard + 'static,
pub fn guard<G>(self, guard: G) -> WebServicewhere
G: Guard + 'static,
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.
Auto Trait Implementations§
impl Freeze for WebService
impl !RefUnwindSafe for WebService
impl !Send for WebService
impl !Sync for WebService
impl Unpin for WebService
impl !UnwindSafe for WebService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more