Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (28 sloc) 898 Bytes

Request Handler

A request handler can be added from file system or from code;

const app = Muneem({
    handlers : "path/for/request/handlers",
app.add("handler", "name", fn);
//app.addHandler("name", fn);


A handler accepts 3 arguments: HttpAsked, HttpAnswer, Store.

A store is the collection of shared resources which can be added as app.set("name", resource).

module.exports = async (asked, answer, giveMe) => {
    const data = await asked.readJson();//read request data
    var db = giveMe("mongo"); //shared resources
    anwser.writeJson( data );//response back

A handler added from the file system should have //@handler, which helps to differentiate other code from request handlers


//.. some code 

module.exports = (asked,answer) => {