vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

Function determineLanguageByHeader

Determines a language code from the value of a header string.

string determineLanguageByHeader(T) (
  string accept_language,
  T allowed_languages
) pure @nogc @safe
if (isForwardRange!T && is(ElementType!T : string) || is(T == typeof(only())));

string determineLanguageByHeader(Tuple...) (
  string accept_language,
  Tuple allowed_languages
) pure @nogc @safe
if (Tuple.length != 1 || is(Tuple[0] : string));

string determineLanguageByHeader(T) (
  HTTPServerRequest req,
  T allowed_languages
) pure @safe
if (isForwardRange!T && is(ElementType!T : string) || is(T == typeof(only())));

string determineLanguageByHeader(Tuple...) (
  HTTPServerRequest req,
  Tuple allowed_languages
) pure @safe
if (Tuple.length != 1 || is(Tuple[0] : string));

Returns

The best match from the Accept-Language header for a language. null if there is no supported language.

Authors

Sönke Ludwig

Copyright

© 2014-2017 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.