Support for unofficial codes?
paambaati opened this issue · 3 comments
Would this project be willing to include non-standard codes as well? I recently ran into a 521
HTTP response, which is apparently Cloudflare's custom HTTP status code for when the origin server is down.
Chasing that status down, I discovered that both nginx and ISS also use their own custom codes. Seeing as how the users of this module are already doing it to lookup status messages for codes, I think there's value in including those as well.
More about the codes here - https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#Unofficial_codes
Can I send a PR?
I'm fine with supporting custom HTTP code but we probably need a pluggable way to handle it to avoid collusions. Maybe on a separate module named after the provider.
I'd also like Cloudflare's custom codes added to this. I see 524 in APIs I call frequently.
Would be pretty simple to add HTTPStatus.includeCloudflareCodes()
or something similar if you don't want them enabled by default.
@ScreamingHawk, right now, require('http-status') return a JSON serializable object in which values are of types string and integer. I believe we should keep it this way and don't add a functions to it. For this reason, I'll propose to create a new module "http-status/lib/cloudfare" which merge cloudfare specific HTTP codes with default value from "http-status/lib/index". We could also export cloudfare specific codes from require('http-status').cloudfare
or require('http-status').vendors.cloudfare