Introduction
Core components of Roa framework.
If you are new to roa, please go to the documentation of roa framework.
Application
A Roa application is a structure containing a middleware group which composes and executes middleware functions in a stack-like manner.
The obligatory hello world application:
use App;
let mut app = new;
app.end;
Cascading
The following example responds with "Hello World", however, the request flows through
the logging
middleware to mark when the request started, then continue
to yield control through the response middleware. When a middleware invokes next.await
the function suspends and passes control to the next middleware defined. After there are no more
middleware to execute downstream, the stack will unwind and each middleware is resumed to perform
its upstream behaviour.
use App;
use Instant;
use info;
let mut app = new;
app.gate_fn;
app.end;
Error Handling
You can catch or straightly throw an Error returned by next.
use ;
use StatusCode;
let mut app = new;
app.gate_fn;
app.gate_fn;
app.end;
error_handler
App has an error_handler to handle Error
thrown by the top middleware.
This is the error_handler:
use ;
pub async
The Error thrown by this error_handler will be handled by hyper.
HTTP Server.
Use roa_core::accept
to construct a http server.
Please refer to crate for more information.