Content Negotiation using the Accept header via the SES interceptor

Description

If extensionDetection is enabled then this will also activate the extension detection via the accept-header

Every incoming HTTP request has a special Accept header that defines what media types (or mime types) a client can "accept". The default of / will be mapped by default to HTML which will be our default format

These types will be mapped in a new structure called mimeTypes that you can declare in your routes configuration file:

<pre><code>

mimeTypes = {
xml = "text/xml",
json = [ "/", "application/json" ]
};
</code></pre>

Once the header Accept is detected and it matches one of these maps, it will set the format request collection variable to the mapped incoming format.

Activity

Show:
Eric Peterson
January 5, 2017, 8:58 PM

Here is a quickly put together version that parses the Accept header after first checking for extensions:

https://gist.github.com/elpete/95282a913762a956e132609736c60660#file-ses-cfc-L40-L57

Luis Majano
January 5, 2017, 9:53 PM

I think this is more than enough for this to be validated. Please look at comments in your gist

Eric Peterson
January 6, 2017, 9:03 PM
Fixed

Assignee

Eric Peterson

Reporter

Luis Majano

Labels

None

Components

Fix versions

Priority

Configure