virto-network / valor

Create HTTP APIs with a plugin system that runs in the server and the browser.
GNU General Public License v3.0
9 stars 8 forks source link

Plugin context data #32

Closed olanod closed 3 years ago

olanod commented 3 years ago

Related to #8 and possibly #13, there should be an easy way to have some state that is shared across requests(e.g. a DB connection). One way is attaching data to context that is passed to requests, middlewares and possible plugin life-cycle hooks.

#[hook]
async fn on_created(cx: &mut Context) {...}

#[vlugin]
async fn handler(req: Request, cx: &Context) -> Response {...}