-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: add text/plain
fallback response
#85
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Douglas Wilson <doug@somethingdoug.com>
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this as a breaking change.
Based on the work in #56.
Adds a fallback
text/plain
response when the client does not accept html.