feat: add text/plain fallback response#85
feat: add text/plain fallback response#85Phillip9587 wants to merge 2 commits intopillarjs:masterfrom
text/plain fallback response#85Conversation
Co-authored-by: Douglas Wilson <doug@somethingdoug.com>
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
wesleytodd
left a comment
There was a problem hiding this comment.
This is a good feature! I just pushed a release though, so we probably want to wait just a little before pushing another. Doesn't mean we shouldn't merge it, but I hate to leave work un-included in express for too long if we dont have to.
|
@wesleytodd We maybe should use |
|
Yeah, probably true. Frankly I dislike all the content type negotiation packages we have, they could use some consolidation and cleanup to make it more clear when to use which. |
|
I don’t think we can include this in a 2.x release since it introduces a breaking change. Currently, |
| var negotiator = new Negotiator(req) | ||
| var type = negotiator.mediaType(['text/html']) | ||
|
|
||
| // construct body | ||
| switch (type) { | ||
| case 'text/html': | ||
| body = createHtmlBody(msg) | ||
| break | ||
| default: | ||
| // default to plain text | ||
| body = createTextBody(msg) | ||
| break | ||
| } |
There was a problem hiding this comment.
I see this as a breaking change.
Based on the work in #56.
Adds a fallback
text/plainresponse when the client does not accept html.