I am writting a class for storing user related data. Is there a way to read/write data from/to "request context"?
For example:
void auth(HTTPServerRequest req, HTTPServerResponse res) {
User user = createUser(req); // creating User class based on request data (session)
storeUser(req, user); // storing user data into request. How to do this?
}
void admin(HTTPServerRequest req, HTTPServerResponse res) {
User user = loadUser(req);
if(!user.isAdmin) throw new HTTPStatusException(HTTPStatus.forbidden);
...
}
shared static this() {
...
router.get("*", &auth);
router.get("/admin", &admin);
...
}
Also has vibe.d some API for read/write data from/to Task/Fiber Local Storage?