Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declarative pattern for response codes #186

Closed
dashby3000 opened this issue Mar 17, 2015 · 4 comments
Closed

Declarative pattern for response codes #186

dashby3000 opened this issue Mar 17, 2015 · 4 comments
Assignees

Comments

@dashby3000
Copy link

In order to return a custom non-error response code, you must implement an afterRemoting hook. The following is an example of an endpoint returning a status of 299.

MyModel.remoteMethod(
   'foo',
   {
     description: 'Do some foo',
     accepts: [
     ],
     returns:{ root: true} ,
     http: {
       verb: 'GET',
       path: '/foo'
     },
     rest: {
       after: function(ctx, cb) {
         ctx.res.status(299);
         cb();
       }
     }
   }
 );

We request a more declarative approach. Something like: returns: { status: 299, root: true }

ref: PLATAPI-234

This would be the mechanism for implementing strongloop/loopback#360

@dashby3000 dashby3000 added this to the #Epic: GoDaddy milestone Mar 17, 2015
@ritch ritch self-assigned this Mar 23, 2015
@ritch
Copy link
Member

ritch commented Mar 27, 2015

Yeah this sounds good... It belongs in the http namespace though.

@bajtos
Copy link
Member

bajtos commented Mar 30, 2015

Another option to consider: annotate a callback argument as holding the HTTP status code

function foo(cb) {
  cb(null, 299);
}
foo.returns = {
  arg: 'httpStatusCode', http: { target: 'statusCode' }
}

@ritch
Copy link
Member

ritch commented Jun 16, 2015

#218

@ritch
Copy link
Member

ritch commented Jun 23, 2015

Released as v2.19.0

@ritch ritch closed this as completed Jun 23, 2015
@ritch ritch removed the #review label Jun 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants