Struct hyper::server::Builder [−][src]
pub struct Builder<I> { /* fields omitted */ }A builder for a Server.
Methods
impl<I> Builder<I>[src]
impl<I> Builder<I>pub fn new(incoming: I, protocol: Http_) -> Self[src]
pub fn new(incoming: I, protocol: Http_) -> SelfStart a new builder, wrapping an incoming stream and low-level options.
For a more convenient constructor, see Server::bind.
pub fn http1_keepalive(self, val: bool) -> Self[src]
pub fn http1_keepalive(self, val: bool) -> SelfSets whether to use keep-alive for HTTP/1 connections.
Default is true.
pub fn http1_only(self, val: bool) -> Self[src]
pub fn http1_only(self, val: bool) -> SelfSets whether HTTP/1 is required.
Default is false.
pub fn http1_writev(self, val: bool) -> Self[src]
pub fn http1_writev(self, val: bool) -> SelfSet whether HTTP/1 connections should try to use vectored writes, or always flatten into a single buffer.
Note
Setting this to false may mean more copies of body data,
but may also improve performance when an IO transport doesn't
support vectored writes well, such as most TLS implementations.
Default is true.
pub fn http2_only(self, val: bool) -> Self[src]
pub fn http2_only(self, val: bool) -> SelfSets 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]
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, 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]
impl Builder<AddrIncoming>pub fn tcp_keepalive(self, keepalive: Option<Duration>) -> Self[src]
pub fn tcp_keepalive(self, keepalive: Option<Duration>) -> SelfSet 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]
pub fn tcp_nodelay(self, enabled: bool) -> SelfSet the value of TCP_NODELAY option for accepted connections.