pub trait Handler: Send + 'static {
// Required method
fn serve(&self, w: &mut ResponseWriter, r: &Request);
}Expand description
Handler is implemented by any type that can process an inbound NWEP request.
The event loop invokes Handler::serve once per request, on the event loop thread.
Closures of type Fn(&mut ResponseWriter, &Request) + Send + 'static implement this
trait automatically, so you can pass a closure wherever a Handler is expected.
Required Methods§
Sourcefn serve(&self, w: &mut ResponseWriter, r: &Request)
fn serve(&self, w: &mut ResponseWriter, r: &Request)
serve processes a single request and writes the response through w.
If serve returns without having called any write method on w, the event loop
automatically sends an empty "ok" response so the stream is always closed cleanly.