Expand description
§rsweb
§library for interacting with the http protocol and creating a multithreaded web server
To create a simple server just use the following code:
use rsweb::resource::ResourceLoader;
use rsweb::route::Router;
use rsweb::server::Server;
use rsweb::config::Config;
let conf = Config {http: None, ssl: None}; // just a config so this example works. In reality you would load a config
let mut server = Server::new(
10, // number of threads
ResourceLoader::new(10, ".".to_string(), true), // create a new resource loader with capacity 10
// and caching enabled
Router::new(), // create a new router with index at index.html
8080, // port
std::net::IpAddr::V4(std::net::Ipv4Addr::new(127,0,0,1)), // ip (localhost in this case)
conf,
);
rsweb
also supports ssl. To create a simple server that uses ssl use:
use rsweb::resource::ResourceLoader;
use rsweb::route::Router;
use rsweb::ssl::SSLServer;
use rsweb::config::Config;
let conf = Config {http: None, ssl: None}; // just a config so this example works.
let mut server = SSLServer::new(
10, // number of threads
ResourceLoader::new(10, ".".to_string(), true), // create a new resource loader with capacity 10 and caching enabled
Router::new(), // create a new router with index at index.html
8080, // port
std::net::IpAddr::V4(std::net::Ipv4Addr::new(127,0,0,1)), // ip (localhost in this case)
String::from("key.pem"), // private key file
String::from("certs.pem"), // certificate chain file
conf,
);
Re-exports§
pub use tp::ThreadPool;
Modules§
- cli
- the cli of
rsweb
- config
- the configuration reading functionality of
rsweb
- dbuffer
- a dynamic buffer implementation used to read from streams
- error
- errors for
rsweb
- http
- HTTP
- log
- logging functions for
rsweb
- resource
- resource handler and cache storage
- route
- router for requests
- server
- basic HTTP server implementation
- ssl
- basic HTTPS server implementation
- tp
- Threadpool implementation included in the logs produced by
log
Macros§
Constants§
- RSWEB_
SERVER_ STR - version str of rsweb used in the
Server
response header - RSWEB_
VERSION - version str of rsweb. Used for logging and CLI