Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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