spaspec / spaspec-standard

Static Page Application Specification Standard
Creative Commons Zero v1.0 Universal
3 stars 0 forks source link

"Accept" header matching #9

Open stuartpb opened 8 years ago

stuartpb commented 8 years ago

As noted in #8, 200.html should only be served in response to a request where text/html is in the Accept header.

At first (as described in #8), I was thinking about using a directive to restrict MIME negotiation. Then, I was thinking about making this something specified as part of the URL, with a hash-fragment in the identifier for handling exotic rules (an idea that would be pretty spooky, in terms of magic-y behavior).

Ultimately, after a little thinking about it, the answer seems pretty obvious: just make content negotiation a part of route matching (at least for 200 responses) - so, if the file that would be served isn't acceptable to the user agent, the route doesn't work.

Indeed, this idea of making content negotiation a part of routing is pretty cool - this might even get supported further with a method like negotiated 200, where multiple file paths can be specified and the winner is served according to content negotiation. (This wouldn't be an extension to the current 200, because I still consider the fourth field onward to be reserved for normal methods.)