0.0.24 • Published 10 years ago

restificant v0.0.24

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

restificant

nodejs easy rest server module

Install

npm install restificant

Usage

//import the module
var restserver = require("restificant");
var FilterObj = require("restificant/FilterObj");

//will get executed at "POST" requests to /apitest 
function apitest(req, res) {
        console.log(req.url);
        res.end("apitest");
};

//will get executed at "GET" requests to /killServer
function killServer(req, res) {
        res.end("stopping server");
        rs.close();
	process.exit(0);
}

//1234 => Listinig port
var rs = new restserver(1234);
//gets triggered if "POST" request to /apitest, third argument is the method the should get called
// methode gets exactly two parameters. the request and the response obj ;-)
rs.addRequestFilter(new FilterObj("POST", /\/apitest/g, apitest));
rs.addRequestFilter(new FilterObj("GET", /\/killServer/g, killServer));
//starts the server to listen
rs.start();
0.0.24

10 years ago

0.0.23

10 years ago

0.0.22

10 years ago

0.0.1

10 years ago