Permalink
Browse files

Docs

  • Loading branch information...
1 parent 6280aab commit eabdc96f75dfeed0f86988eb0d6b2c15052c3dcf @akaspin committed Nov 10, 2010
Showing with 23 additions and 3 deletions.
  1. +21 −2 chain/cookie.md
  2. +2 −1 readme.md
View
@@ -84,7 +84,6 @@ If for any reason you don't want to decorate `writeHead` method, just add
var kaphCookie = require('kaph/chain/cookie');
http.createServer(function(request, response) {
- // Make cookies object
var cookie = new kaphCookie.Proc(request.headers, response, true);
cookie.set('simple', 'Simple value');
@@ -104,6 +103,26 @@ This module provides *operation* to use with *kaph*. Usage is similar to that
described above. With one difference - operation creates a new object `cookies`
inside *kaph* handler.
+ var http = require('http');
+ var HttpHandler = require('kaph/http').Handler;
+ var kaphCookie = require('kaph/chain/cookie');
+
+ Op = {
+ GET: function() {
+ this.cookies.set('simple', 'Simple value');
+ var simple = this.cookies.get('simple');
+
+ this.response.writeHead(200,
+ {'Content-Type': "text/html; charset=UTF-8"});
+ this.response.end('simple: ' + simple);
+ }
+ };
+
+ var chain = [kaphCookie.Op, Op];
+
+ http.createServer(function(request, response) {
+ (new HttpHandler(request, response, chain)).next();
+ }).listen(9080);
-
+## Pitfalls
View
@@ -99,7 +99,8 @@ you find a few things that can make life much more pleasant:
* [writer](https://github.com/akaspin/kaph/blob/master/chain/writer.md) -
facade for working with `http.ServerResponse`
-Each of them can be used independently of *kaph*.
+Each of them can be used independently of *kaph*. And of course *kaph*,
+not depend on them.
## How about router?

0 comments on commit eabdc96

Please sign in to comment.