Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Allow to have middleware for the path same with a HTML page #236

Merged
merged 3 commits into from
May 4, 2018

Conversation

akihikodaki
Copy link
Contributor

HTTP allows to change the type of the content to serve by Accept field in
the request. The middleware for the path same with a HTML page will
be inserted before the HTML renderer, and can take advantage of this
feature, using expressjs's "accepts" method, for example.

HTTP allows to change the type of the content to serve by Accept field in
the request. The middleware for the path same with a HTML page will
be inserted before the HTML renderer, and can take advantage of this
feature, using expressjs's "accepts" method, for example.
@Rich-Harris
Copy link
Member

Thanks for this — I think I understand it, and it seems sensible, but just to help me make sure I've got this down, could you walk me through a scenario where you'd use this, and what the middleware would look like?

@akihikodaki
Copy link
Contributor Author

Here is a simple example: https://github.com/miniorg/miniverse/blob/6e8a82c8036d62df4f3d5b2303cd907e3b7c05fa/routes/%40%5Bacct%5D/index.js

If the user agent prefers application/activity+json or application/ld+json, it returns a representation of a person in format called JSON ActivityStreams. If the user agent prefers text/html or shows no preference, an HTML representation will be served.

@Rich-Harris Rich-Harris merged commit 9e2d0a7 into sveltejs:master May 4, 2018
@Rich-Harris
Copy link
Member

sounds good — thanks for the clarification

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants