pub struct Server<F> { /* fields omitted */ }
A listening server.
This struct is the more manual server creation API of rouille and can be used as an alternative
to the start_server
function.
The start_server
function is just a shortcut for Server::new
followed with run
. See the
documentation of the start_server
function for more details about the handler.
use rouille::Server;
use rouille::Response;
let server = Server::new("localhost:0", |request| {
Response::text("hello world")
}).unwrap();
println!("Listening on {:?}", server.server_addr());
server.run();
Builds a new Server
object.
After this function returns, the HTTP server is listening.
Returns an error if there was an error while creating the listening socket, for example if
the port is already in use.
Use a ThreadPool
of the given size to process requests
pool_size
must be greater than zero or this function will panic.
Returns the address of the listening socket.
Runs the server forever, or until the listening socket is somehow force-closed by the
operating system.
Processes all the client requests waiting to be processed, then returns.
This function executes very quickly, as each client requests that needs to be processed
is processed in a separate thread.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static