Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loose-coupled set of tools for handle requests under node.js

tree: 2f6d379845

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.md

kaph*

kaph is router-independent request handler for node.js.

*In the Phoenician alphabet letter "kaph" indicates palm.

Usage

kaph does not interfere in node.js API. All that kaph do is two exports for simplify response flow control:

var sys = require("sys");
var http = require("http");
var kaph = require("kaph");

function Handler(request, response, context, args) {
    kaph.Handler.call(this, request, response, args);
    this.context = context;
}
sys.inherits(Handler, kaph.Handler);

Handler.prototype.GET = function(name) {
    if (name == undefined) {
        throw new kaph.HttpError(404, "Not Found, wrong url");
    } else {
        this.end("Handled! " + name + "<br />" + 
                "Setting: " + this.context.setting);
    }
};

var context = {setting: "Some setting"};

http.createServer(function (request, response) {
    var args = [];
    if (request.url != '/') {
        args = [request.url];
    }

    (new Handler(request, response, context, args)).execute();
}).listen(8888);

So what does this mean? kaph

Something went wrong with that request. Please try again.