Crate shrimple_localhost
source ·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§
- Server for serving files locally
Enums§
- The result of a request. This doesn’t report IO errors, since in a case of such error no request is registered.
- 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§
- Serve files from
rootat portServer::DEFAULT_PORT
If a custom port needs to be provided, useserve_at
Ifrootis only ever supposed to be the current directory, useserve_current_dir - Serve files from
rootataddr
If it doesn’t matter what port is used, useserve
Ifrootis only ever supposed to be the current directory, useserve_current_dir_at - Serve files from the current directory at port
Server::DEFAULT_PORT
If a custom port needs to be provided, useserve_current_dir_at
If a custom root needs to be provided, useserve - Serve files from
rootat portServer::DEFAULT_PORT
If it doesn’t matter what port is used, useserve_current_dir
If a custom root needs to be provided, useserve_at