-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed utf8 handling. Fixed long payloads issue. Updated docsand tests
- Loading branch information
1 parent
9db895f
commit 32af574
Showing
14 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ A library that allows other projects to be agnostic of particular http server im | |
*Notice of change of ownership: Starting version 1.0.0 this package has changed it's owner and goals. Old version (0.0.0) is still available on npm via `npm install [email protected]` or on [github](https://github.com/dtudury/agnostic). Thank you.* | ||
|
||
|
||
| node / libs | express | restify | hapi | http | | ||
| node / libs | express | restify | hapi | http | | ||
| :-- | :-- | :-- | :-- | :-- | | ||
| v0.12 | 3.x, 4.x | 2.x, 3.x, 4.x | 8.x, 9.x, 10.x | ✓ | | ||
| io.js | 3.x, 4.x | 2.x, 3.x, 4.x | 8.x, 9.x, 10.x | ✓ | | ||
|
@@ -39,11 +39,20 @@ var agnostic = require('agnostic'); | |
|
||
module.exports = agnostic(myRequestHandler); | ||
|
||
/** | ||
* Does cool things | ||
* | ||
* @param {EventEmitter} request - request object, mimicking IncomingMessage | ||
* @param {Function} respond - callback to respond to the request | ||
*/ | ||
function myRequestHandler(request, respond) | ||
{ | ||
// do cool things | ||
// `request.body` - parsed request body | ||
// `request.query` - parsed query string | ||
// `respond` is a function with the following signature: | ||
// `respond([code], [content[, options]]);` | ||
respond(200, 'Received hit to ' + request.url, {headers: {'X-Powered-By': 'AllCoolThings'}}); | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
'method': 'POST', | ||
'headers': { | ||
'host': 'localhost', | ||
'accept': '*/*', | ||
'content-type': 'application/json' | ||
}, | ||
'body': { | ||
'message': { | ||
'text': 'the naïve assumption' | ||
} | ||
}, | ||
|
||
requestHandler: function(req, res) | ||
{ | ||
res(200, {object: req.body.message.text}); | ||
}, | ||
|
||
'expected': | ||
{ | ||
'status': 200, | ||
'body' : '{"object":"the naïve assumption"}', | ||
'headers': { | ||
'content-type': 'application/json' | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
'method': 'POST', | ||
'headers': { | ||
'host': 'localhost' | ||
}, | ||
'body': '{ body payload is too long, but still handled properly and with a meaningful response code and human readable error message }', | ||
|
||
requestHandler: function(req, res) | ||
{ | ||
res(200, {should_not: 'been here'}); | ||
}, | ||
|
||
'expected': | ||
{ | ||
'status': 413, | ||
'body': 'request entity too large' | ||
}, | ||
|
||
'expected.hapi': | ||
{ | ||
'status': 400, | ||
'body': '{"statusCode":400,"error":"Bad Request","message":"Payload content length greater than maximum allowed: 100"}' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters