-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
About Customize HTTP Status Codes #350
Comments
i made it easier to add custom status codes in for custom status codes, it might actually be easier to add the status codes globally to the var statuses = require('statuses');
statuses['700'] = 'custom status'; lol |
@zedgu can you tell me if changing the statuses module globally works for you? |
Actually, we need status codes for http response header, not a simple message for node server side console. And, we only got var koa = require('koa')
, app = koa()
, statuses = require('statuses')
;
statuses['440'] = 'login expired';
app.use(function *(next) {
this.throw(440);
yield next;
});
app.listen(3000); anything wrong? Should we just don't check http.STATUS_CODES in here https://github.com/koajs/koa/blob/master/lib/context.js#L129 , |
change this line to https://github.com/jshttp/http-errors/blob/master/index.js#L31 you can make a PR |
my fault, this line https://github.com/koajs/koa/blob/master/lib/response.js#L72 is the problem and i'd love to make the PR |
yep, you should change them both. :) |
oh yeah. both should be less strict. PR welcomed :) |
add res.message[=]
We have to use the customize HTTP codes for some reasons like
login expired
(code 440 , see http:https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) or customize code range 7xx.But they'll throw Error by both API
this.status
andthis.throw
, because there're only RFC codes in http.STATUS_CODES and jshttp/statuses/codes.json.Should we let koa to support the customize HTTP status codes?
The text was updated successfully, but these errors were encountered: