Three level granularity (global, module, function handler) middleware controller and unified middleware presentation;
Typesafe abstraction, keep the same spirit with hyper;
For easy using, will supply some convenient macros to help write business logics;
Global object cross requests;
Philosophy
Typed, hierarchical control, and middlewares.
Typed
In Sapper, nearly every important thing is a Type. They are:
Each module is a type, different modules are different types;
Every middleware supplies some (0 to n) types for handler getting values;
Inherited from hyper's typed spirit, all headers, mime and so on should use types for manipulation.
Hierarchical Control
Sapper forces you to put router in each module (in main.rs, you can not write it, no space left for you to write);
Sapper forces you to seperate the router binding and the handler realization;
Sapper's plugin processor can be used in app level wrapper, module level wrapper, and each handler. These three level hierarchical controls make it flexible to construct your business.
Middlewares
Sapper's core contains only router system, request and response definitions, middleware system, and some other basic facilities. Nearly all practical features, such as query parameter, body parameter, cookie, session, json, xml, orm..., are supplied by the corresponding middlewares.
Sapper's middleware is very easy to write. One rust module realized a function on the prototype of
rust
fn (&mut Request) ->Result; // before pluginfn (&Request, &mut Response) ->Result; // after plugin
can be thought as Sapper's middleware. Sample middleware: sapper_query.