Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 82 lines (55 sloc) 2.541 kB
f0f71b2 @tj Initial commit
tj authored
1
2 # Express Contrib
3
4 The _express-namespace_ module provides namespace capabilities to express.
5
6 ## Installation
7
8 npm:
9
10 $ npm install express-namespace
11
12 ## Usage
13
14 The example below may respond to any of the following requests:
15
16 GET /forum/12
17 GET /forum/12/view
18 GET /forum/12/edit
19 GET /forum/12/thread/5
20 DELETE /forum/12
21
22 To utilize this module simply `require('express-namespace')` and `app.namespace()` will automatically be available to you.
23
24 Usage is as follows, simply pass a callback function and route to the method, after each callback invocation is complete, the namespace is restored to it's previous state.
25
26 app.namespace('/forum/:id', function(){
27 app.get('/(view)?', function(req, res){
28 res.send('GET forum ' + req.params.id);
29 });
30
31 app.get('/edit', function(req, res){
32 res.send('GET forum ' + req.params.id + ' edit page');
33 });
34
35 app.namespace('/thread', function(){
36 app.get('/:tid', function(req, res){
37 res.send('GET forum ' + req.params.id + ' thread ' + req.params.tid);
38 });
39 });
40
41 app.del('/', function(req, res){
42 res.send('DELETE forum ' + req.params.id);
43 });
44 });
45
46 You can also access the current namespace via `app.currentNamespace`;
47
48 ## Running Tests
49
50 First make sure you have the submodules:
51
52 $ git submodule update --init
53
54 Then run the tests:
55
56 $ make test
57
58 ## License
59
60 (The MIT License)
61
62 Copyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>
63
64 Permission is hereby granted, free of charge, to any person obtaining
65 a copy of this software and associated documentation files (the
66 'Software'), to deal in the Software without restriction, including
67 without limitation the rights to use, copy, modify, merge, publish,
68 distribute, sublicense, and/or sell copies of the Software, and to
69 permit persons to whom the Software is furnished to do so, subject to
70 the following conditions:
71
72 The above copyright notice and this permission notice shall be
73 included in all copies or substantial portions of the Software.
74
75 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
76 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
78 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
79 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
80 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
81 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.