pub struct HttpServer { /* private fields */ }

Implementations

create an instance of http server

  • end: use end_point![0.0.0.0:8080] to construct EndPoint
  • count: specify the size of thread pool

This method specifies the value of time when waiting for the read from the client.

  • [unit: millisecond]

This method specifies the value of time when waiting for the read of the client

  • [unit: millisecond]

Specifiy each chunk size when responding to the client by using Chunked Transfer,

  • [unit: byte]

The switch to output the error in the connection the server has caught

Specify the maximum size of body in a connection the server can handle

  • [unit: byte]

Specify the maximum size of http header in a connection the server can handle

  • [unit: byte]

Specify the increased size of buffers used for taking the content of the stream in a connection

  • [unit: byte]

To start a http server

  • This is a block method, which implies all set to the instance of HttpServer should precede the call of this method

Register a router

  • methods: Http Method

allow the form: single method GET, or multiple methods [GET, HEAD]

  • path: Http Url to which the router respond
Usage:

HttpServer::route(HttpServer::GET, “/”).reg(…)

  • the call of reg registers the action
  • the argument shall satisfy the trait Router
  • Router is automatically implemented for type fn and FnMut that takes two parameters &Request and & mut Response

HttpServer::route(HttpServer::GET, “/”).reg_with_middlewares(…)

  • register a router with a set of middlwares
  • The first argument is a set of middlwares
  • A middleware satisfies trait MiddleWare

In the above cases, the path can a wildcard url, such as /path/*

  • A valid wildcard path cannot be /*

Specify the action when a request does not have a corresponding registered router

  • The framework has a preset action, you can overwrite it by using this method
  • The argument shall satisfy constraint: Router + Send + Sync + ’static

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.