Expand description
Zero-dependency simple synchronous localhost server. The 2 ways to use the library are:
serve_current_dir,serve,serve_current_dir_at,serve_atfunctions, the simpler approach.Serverstruct, the more complex approach.
If inspecting incoming connections & requests is needed (e.g. for logging), the 2nd approach will be better, otherwise the 1st one will be easier.
Structs§
Enums§
- Request
Result - The result of a request. This doesn’t report IO errors, since in a case of such error no request is registered.
- Response
- Server’s response to a request.
- Server
Error - Error returned by
Server::try_serve_with_callbackthat differentiates between an IO error from within the server and an error propagated from a callback.
Functions§
- print_
request_ result - Default function for printing the result of a request along with the IP from which it came.
Can be passed to
Server::serve_with_callback. - serve
- Serve files from
rootat portServer::DEFAULT_PORT - serve_
at - Serve files from
rootataddr - serve_
current_ dir - Serve files from the current directory at port
Server::DEFAULT_PORT - serve_
current_ dir_ at - Serve files from
rootat portServer::DEFAULT_PORT