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 composing and executing middlewares and an endpoint in a stack-like manner.
The obligatory hello world application:
use ;
let app = new.end;
// endpoint
async
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 endpoint. When a middleware invokes next.await
the function suspends and passes control to the next middleware or endpoint. After the endpoint is called,
the stack will unwind and each middleware is resumed to perform
its upstream behaviour.
use ;
use Instant;
use info;
let app = new.gate.end;
async
async
Status Handling
You can catch or straightly throw an status returned by next.
use ;
use StatusCode;
let app = new.gate.gate.end;
async
async
async
status_handler
App has an status_handler to handle Status
thrown by the top middleware.
This is the status_handler:
use ;
HTTP Server.
Use roa_core::accept
to construct a http server.
Please refer to roa::tcp
for more information.