Struct actix_http::HttpService
source · [−]pub struct HttpService<T, S, B, X = ExpectHandler, U = UpgradeHandler> { /* private fields */ }
Expand description
A ServiceFactory
for HTTP/1.1 or HTTP/2 protocol.
Implementations
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TlsStream<TcpStream>, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TlsStream<TcpStream>, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
pub fn openssl(
self,
acceptor: SslAcceptor
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = TlsError<SslError, DispatchError>, InitError = ()>
pub fn openssl(
self,
acceptor: SslAcceptor
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = TlsError<SslError, DispatchError>, InitError = ()>
Create OpenSSL based service.
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TlsStream<TcpStream>, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
impl<S, B, X, U> HttpService<TlsStream<TcpStream>, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TlsStream<TcpStream>, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
pub fn rustls(
self,
config: ServerConfig
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = TlsError<Error, DispatchError>, InitError = ()>
pub fn rustls(
self,
config: ServerConfig
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = TlsError<Error, DispatchError>, InitError = ()>
Create Rustls based service.
Constructs builder for HttpService
instance.
Constructs new HttpService
instance from service with default config.
Sets service for Expect: 100-Continue
handling.
An expect service is called with requests that contain an Expect
header. A successful
response type is also a request which will be forwarded to the main service.
Sets service for custom Connection: Upgrade
handling.
If service is provided then normal requests handling get halted and this service get called with original request and framed object.
impl<S, B, X, U> HttpService<TcpStream, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TcpStream, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
impl<S, B, X, U> HttpService<TcpStream, S, B, X, U> where
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<TcpStream, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
pub fn tcp(
self
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = DispatchError, InitError = ()>
pub fn tcp(
self
) -> impl ServiceFactory<TcpStream, Config = (), Response = (), Error = DispatchError, InitError = ()>
Create simple tcp stream service
Trait Implementations
impl<T, S, B, X, U> ServiceFactory<(T, Protocol, Option<SocketAddr>)> for HttpService<T, S, B, X, U> where
T: AsyncRead + AsyncWrite + Unpin + 'static,
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
impl<T, S, B, X, U> ServiceFactory<(T, Protocol, Option<SocketAddr>)> for HttpService<T, S, B, X, U> where
T: AsyncRead + AsyncWrite + Unpin + 'static,
S: ServiceFactory<Request, Config = ()>,
S::Future: 'static,
S::Error: Into<Response<BoxBody>> + 'static,
S::InitError: Debug,
S::Response: Into<Response<B>> + 'static,
<S::Service as Service<Request>>::Future: 'static,
B: MessageBody + 'static,
X: ServiceFactory<Request, Config = (), Response = Request>,
X::Future: 'static,
X::Error: Into<Response<BoxBody>>,
X::InitError: Debug,
U: ServiceFactory<(Request, Framed<T, Codec>), Config = (), Response = ()>,
U::Future: 'static,
U::Error: Display + Into<Response<BoxBody>>,
U::InitError: Debug,
type Error = DispatchError
type Error = DispatchError
Errors produced by the created services.
The kind of Service
created by this factory.
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>
type Future = LocalBoxFuture<'static, Result<Self::Service, Self::InitError>>
The future of the Service
instance.g
Create and return a new service asynchronously.
Auto Trait Implementations
impl<T, S, B, X = ExpectHandler, U = UpgradeHandler> !RefUnwindSafe for HttpService<T, S, B, X, U>
impl<T, S, B, X = ExpectHandler, U = UpgradeHandler> !Send for HttpService<T, S, B, X, U>
impl<T, S, B, X = ExpectHandler, U = UpgradeHandler> !Sync for HttpService<T, S, B, X, U>
impl<T, S, B, X, U> Unpin for HttpService<T, S, B, X, U> where
B: Unpin,
S: Unpin,
U: Unpin,
X: Unpin,
impl<T, S, B, X = ExpectHandler, U = UpgradeHandler> !UnwindSafe for HttpService<T, S, B, X, U>
Blanket Implementations
Mutably borrows from an owned value. Read more
Convert Self
to a ServiceFactory
Map this service’s output to a different type, returning a new service of the resulting type. Read more
Map this service’s error to a different error, returning a new service.
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, Req, E> where
F: Fn(Self::InitError) -> E + Clone,
fn map_init_err<F, E>(self, f: F) -> MapInitErr<Self, F, Req, E> where
F: Fn(Self::InitError) -> E + Clone,
Map this factory’s init error to a different error, returning a new service.
Call another service after call to this one has resolved successfully.