Skip to content

Support for RFC6839 #1839

@ghermeto

Description

@ghermeto

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions