0.2.7 • Published 10 years ago

qweb v0.2.7

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

qweb

A very simple web framework

install

npm install qweb --save

init

var qweb = require('qweb');
var server = qweb();

basic dict route

qweb({path: handler})

var server = qweb({
    '/foo': function(req, res) {
        res.end('foo');
    }
});

route with method

Support ALL HTTP Verb like GET, POST, PUT, ...

var server = qweb();
server.get('/foo', function(req, res) {
});

server.post('/foo', function(req, res) {
});

route with named params

qweb().get('/foo/:id', function(req, res) {
        res.end(req.params.id);
});

route or wild-card.

qweb().get('/foo/*', function(req, res) {
        res.end(req.params[0]);
});

req.query

qweb().get('/foo', function(req, res) {
    console.log(req.query);
});

req.res

res.req

server.before(function(req, res))

server.after(function(req, res))

Event: domainError function(error, req, res)

extend request and response.

You can extend request and response method by below method.

qweb.res.json = function(obj) {
    this.writeHead({'Content-Type': 'application/json'});
    this.end(JSON.stringify(obj));
}
0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago