https://github.com/ullmark/restify-jsonpmethodoverride
A handler for restify that adds JSONP method override capabilities.
https://github.com/ullmark/restify-jsonpmethodoverride
Last synced: about 1 month ago
JSON representation
A handler for restify that adds JSONP method override capabilities.
- Host: GitHub
- URL: https://github.com/ullmark/restify-jsonpmethodoverride
- Owner: ullmark
- Created: 2013-04-15T16:12:50.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-05-08T13:29:50.000Z (about 13 years ago)
- Last Synced: 2025-03-21T16:15:57.607Z (over 1 year ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
restify-jsonpmethodoverride
===========================
What is?
---------------------
Creating an APi and enabling it for javascript browser clients can be a bit of a pain if you want
to keep your APi clean by working with the HTTP Verbs for CRUD since anything other than **GET** is
impossible in JSONP.
Usage
---------------------
```javascript
var restify = require('restify'),
jsonpOverride = require('restify-jsonpoverride');
var server = restify.createServer();
// query parser is needed, for the override and therefor must be configured as
// a pre. **mapParams** must be set to false due to bug in query parser
server.pre(restify.queryParser( mapParams: false ));
server.pre(jsonpMethodOverride());
server.use(restify.jsonp());
// this route is executed on
// **POST**: /foo
// **GET**: /foo?_method=POST&callback=something
server.post('/foo', function(req, res, next) {
});
```