restify / restify/node-restify
Support for RFC6839
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
Additional media types (+json)
What?
Support RFC6839 allowing formatters for additional media types structured with syntax suffixes, like +json.
Valid examples are: application/calendar+json, application/problem+json, application/geo+json, etc (the full list can be seen on mime-db)...
Why?
Right now if you try to follow RFC7807 and send back a Content-Type application/problem+json, it won't find the correct formatter (which is json) and will override the content-type to application/octet-stream.
Example API
server.get('/', function (req, res, next) {
res.contentType = 'problem+json';
res.send({
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50."
});
});
Are you willing and able to implement this?
I'm converting PR #1786 from RFC7807 to RFC6839 and we can tackle RFC7807 on a separate issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the server.get example reaches res.contentType and res.send, then locate the formatter selection for media types. Verify behavior with application/problem+json and the other RFC6839 +json examples; done means the json formatter is selected without replacing the declared content type with application/octet-stream.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100