Merge pull request #716 from strongloop/revert-708-rest-options
Revert "rest handler options"
This commit is contained in:
commit
2d0b74b007
|
@ -12,21 +12,20 @@ module.exports = rest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose models over REST.
|
* Expose models over REST.
|
||||||
*
|
*
|
||||||
* For example:
|
* For example:
|
||||||
* ```js
|
* ```js
|
||||||
* app.use(loopback.rest());
|
* app.use(loopback.rest());
|
||||||
* ```
|
* ```
|
||||||
* For more information, see [Exposing models over a REST API](http://docs.strongloop.com/display/DOC/Exposing+models+over+a+REST+API).
|
* For more information, see [Exposing models over a REST API](http://docs.strongloop.com/display/DOC/Exposing+models+over+a+REST+API).
|
||||||
* @header loopback.rest()
|
* @header loopback.rest()
|
||||||
* @param {Object} options REST handler options.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function rest(options) {
|
function rest() {
|
||||||
var tokenParser = null;
|
var tokenParser = null;
|
||||||
return function (req, res, next) {
|
return function (req, res, next) {
|
||||||
var app = req.app;
|
var app = req.app;
|
||||||
var handler = app.handler('rest', options);
|
var handler = app.handler('rest');
|
||||||
|
|
||||||
if(req.url === '/routes') {
|
if(req.url === '/routes') {
|
||||||
res.send(handler.adapter.allRoutes());
|
res.send(handler.adapter.allRoutes());
|
||||||
|
|
|
@ -75,16 +75,6 @@ describe('loopback.rest', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support options', function(done) {
|
|
||||||
app.model(MyModel);
|
|
||||||
var supportedTypes = ['json', 'application/javascript', 'text/javascript'];
|
|
||||||
app.use(loopback.rest({supportedTypes: supportedTypes}));
|
|
||||||
request(app).get('/mymodels')
|
|
||||||
.set('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8')
|
|
||||||
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
||||||
.expect(200, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('includes loopback.token when necessary', function(done) {
|
it('includes loopback.token when necessary', function(done) {
|
||||||
givenUserModelWithAuth();
|
givenUserModelWithAuth();
|
||||||
app.enableAuth();
|
app.enableAuth();
|
||||||
|
|
Loading…
Reference in New Issue