get_matching_content_type

fnint get_matching_content_type(T...)(string req_content_types_str) pure @safe

The client sends the list of allowed content types in the 'Allow' http header and the response will contain a 'Content-Type' header. This function will try to find the best matching @SerializationResult UDA based on the allowed content types.

Note

Comment 1: if the request doesn't specify any allowed content types, then /

is assumed

Comment 2: if there are no UDA's matching the client's allowed content types, -1 is returned

Comment 3: if there are more than 1 matching UDA, for ONE specific client's allowed content type(and their priority is the same - see below), then the one specified earlier in the code gets chosen

Comment 4: accept-params(quality factor) and accept-extensions are ignored

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Comment 5: matching the most specific content type without any wildcard has priority

Comment 6: the request's content type can be in the format of

  • major type / minor type
  • major type / *
  • /

Parameters

Tcompile time known ResultSerializer classes
req_content_types_strlist of allowed content types for example: text/*;q=0.3, text/html;q=0.7, text/html;level=1

Returns

index of the result serializers in the T... AliasSeq if matching found,

-1 otherwise