Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Docs and typo

  • Loading branch information...
commit 6280aabf95fa2e9cddbfb4296b182ab60e968a08 1 parent f79c5db
@akaspin authored
Showing with 17 additions and 3 deletions.
  1. +1 −0  chain/cookie.js
  2. +15 −2 chain/cookie.md
  3. +1 −1  http.js
View
1  chain/cookie.js
@@ -27,6 +27,7 @@ function Proc(headers, response, dontDecorate) {
this._dontDecorate = dontDecorate;
}
exports.Proc = Proc;
+
/**
* Set cookie. If needed, at first call decorates method `writeHead` of
* instance `http.ServerResponse`.
View
17 chain/cookie.md
@@ -28,16 +28,19 @@ argiments given to constructor: `request.headers` and `response`.
// ... and encrypted
cookie.set('encrypted', 'Secret value', {days: 30}, true);
- // get some cookies
+ // Get some cookies
var simple = cookie.get('simple');
var encrypted = cookie.get('encrypted', true);
+ // And kill!
+ cookie.clear('notneeded');
+
response.writeHead(200, {'Content-Type': "text/html"});
response.end('simple: ' + simple +
', encrypted: ' + encrypted);
}).listen(9080);
-New `cookie` object has two methods `set` and `get`.
+New `cookie` object has three methods `set`, `get` and `clear`.
`set` method of `cookie` object as is evident from its name, sets new cookie
and takes four arguments:
@@ -60,6 +63,9 @@ Cookie `options` is object that may contain several optional properties:
`get` method takes two arguments `name` and `decrypt` (see below), and returns
cookie value or `undefined` if cookie not exists.
+Also you can unset cookies with `clear` method that takes only one parameter -
+cookie name.
+
### Encrypted cookies
You can encrypt and decrypt your cookies. All that is needed for this - set
@@ -94,3 +100,10 @@ cookies by `deploy` method, that returns `Array` of prepared cookies.
## Kaph chain usage
+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.
+
+
+
+
View
2  http.js
@@ -30,7 +30,7 @@ exports.Handler = Handler;
*/
Handler.prototype.next = function() {
this._level++;
- var op = this.chain[this._level];
+ var op = this._chain[this._level];
try {
var meth = op[this.request.method] || op['DEFAULT'];
if (!meth) throw new HandlerError(405, 'Operation hasn\'t methods ' +
Please sign in to comment.
Something went wrong with that request. Please try again.