Struct hyper::server::Builder
[−]
[src]
pub struct Builder<I> { /* fields omitted */ }
A builder for a Server
.
Methods
impl<I> Builder<I>
[src]
pub fn new(incoming: I, protocol: Http_) -> Self
[src]
Start a new builder, wrapping an incoming stream and low-level options.
For a more convenient constructor, see Server::bind
.
pub fn http2_only(self, val: bool) -> Self
[src]
Sets whether HTTP/2 is required.
Default is false
.
pub fn serve<S, B>(self, new_service: S) -> Server<I, S> where
I: Stream,
I::Error: Into<Box<Error + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: NewService<ReqBody = Body, ResBody = B> + Send + 'static,
S::Error: Into<Box<Error + Send + Sync>>,
S::Service: Send,
<S::Service as Service>::Future: Send + 'static,
B: Payload,
[src]
I: Stream,
I::Error: Into<Box<Error + Send + Sync>>,
I::Item: AsyncRead + AsyncWrite + Send + 'static,
S: NewService<ReqBody = Body, ResBody = B> + Send + 'static,
S::Error: Into<Box<Error + Send + Sync>>,
S::Service: Send,
<S::Service as Service>::Future: Send + 'static,
B: Payload,
Consume this Builder
, creating a Server
.
Example
use hyper::{Body, Response, Server}; use hyper::service::service_fn_ok; // Construct our SocketAddr to listen on... let addr = ([127, 0, 0, 1], 3000).into(); // And a NewService to handle each connection... let new_service = || { service_fn_ok(|_req| { Response::new(Body::from("Hello World")) }) }; // Then bind and serve... let server = Server::bind(&addr) .serve(new_service); // Finally, spawn `server` onto an Executor...
impl Builder<AddrIncoming>
[src]
pub fn tcp_keepalive(self, keepalive: Option<Duration>) -> Self
[src]
Set whether TCP keepalive messages are enabled on accepted connections.
If None
is specified, keepalive is disabled, otherwise the duration
specified will be the time to remain idle before sending TCP keepalive
probes.
pub fn tcp_nodelay(self, enabled: bool) -> Self
[src]
Set the value of TCP_NODELAY
option for accepted connections.