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

HTTP status codes #65

Closed
ahdinosaur opened this issue May 22, 2014 · 8 comments · Fixed by #71
Closed

HTTP status codes #65

ahdinosaur opened this issue May 22, 2014 · 8 comments · Fixed by #71
Milestone

Comments

@ahdinosaur
Copy link

hi,

how does one send an HTTP status code other than 200, either on success or on error? i'm trying to follow HTTP API best practices, something similar to this.

cheers!

ahdinosaur pushed a commit to ahdinosaur-deprecated/people-api that referenced this issue May 23, 2014
@ahdinosaur
Copy link
Author

ah, now i see #38 for errors. is there a way to send non-error custom status codes?

@ahdinosaur
Copy link
Author

this may be something better handled by feathers as it is specific to RESTful HTTP. specifically i was thinking about 201 status and Location header on create and 204 status when response is empty. is this appropriate?

@daffl
Copy link
Member

daffl commented May 23, 2014

This would be a good thing to add. Always looking for more ways to improve the REST provider. Although, you should be able to implement this functionality already using a custom middleware (req.data is the data returned by your service):

var app = feathers()
  .use('/todos', todoService)
  .use(function(req, res, next) {
    if(_.isEmpty(req.data)) {
      res.status = 204;
    }

    if(req.method === 'POST') {
      res.status = 201;
    }

    next();
  });

app.listen(8080);

@daffl daffl added this to the 1.0.0 milestone May 23, 2014
@ahdinosaur
Copy link
Author

ah, awesome, thank you.

@daffl
Copy link
Member

daffl commented Jun 1, 2014

I'm wondering if it should still send a 204 when the response is {} is an empty object equals to an empty response? Besides that we could easily add those status codes to the REST handler.

@jgillich
Copy link

jgillich commented Jun 2, 2014

IMHO an empty object is still a response (just like an empty array). I would consider null to be an empty response.

@ahdinosaur
Copy link
Author

i agreed with @jgillich.

daffl added a commit that referenced this issue Jun 4, 2014
@daffl daffl closed this as completed in #71 Jun 4, 2014
daffl pushed a commit that referenced this issue Aug 19, 2018
Add ability to skip all following hooks
daffl added a commit that referenced this issue Aug 19, 2018
daffl pushed a commit that referenced this issue Aug 21, 2018
Add ability to skip all following hooks
daffl added a commit that referenced this issue Aug 21, 2018
daffl pushed a commit that referenced this issue Aug 21, 2018
…ting (#65)

* Add namespace to enable `import * as from` syntax in TS

* Add ? to options
daffl pushed a commit that referenced this issue Aug 22, 2018
…ting (#65)

* Add namespace to enable `import * as from` syntax in TS

* Add ? to options
daffl pushed a commit that referenced this issue Aug 25, 2018
Addng an update prompt when any generators are invoked
daffl pushed a commit that referenced this issue Aug 28, 2018
* chore(package): update sinon to version 6.0.0

* Update Travis install script
daffl pushed a commit that referenced this issue Aug 29, 2018
daffl pushed a commit that referenced this issue Aug 29, 2018
Removing assigning token to params.query for sockets. Closes #65.
daffl pushed a commit that referenced this issue Aug 29, 2018
* chore(package): update sinon to version 6.0.0

* Update Travis install script
daffl pushed a commit that referenced this issue Aug 29, 2018
daffl pushed a commit that referenced this issue Aug 29, 2018
Removing assigning token to params.query for sockets. Closes #65.
@lock
Copy link

lock bot commented Feb 8, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants