MediaRange

play.api.http.MediaRange
See theMediaRange companion class
object MediaRange

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
MediaRange.type

Members list

Type members

Classlikes

object parse

Function and extractor object for parsing media ranges.

Function and extractor object for parsing media ranges.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
parse.type

Value members

Concrete methods

def preferred(acceptableRanges: Seq[MediaRange], availableMediaTypes: Seq[String]): Option[String]

Given a list of acceptable media ranges, find the preferred media type in the list of available media types.

Given a list of acceptable media ranges, find the preferred media type in the list of available media types.

Note: the media types in the list should be without parameters, e.g. text/html not text/html;charset=utf-8

Attributes

Implicits

Implicits

implicit val ordering: Ordering[MediaRange]

Ordering for MediaRanges, in order of highest priority to lowest priority.

Ordering for MediaRanges, in order of highest priority to lowest priority.

The reason it is highest to lowest instead of lowest to highest is to ensure sorting is stable, so if two media ranges have the same ordering weight, they will not change order.

Ordering rules for MediaRanges:

First compare by qValue, default to 1. Higher means higher priority. Then compare the media type. If they are not the same, then the least specific (ie, if one is *) has a lower priority, otherwise if they have same priority. Then compare the sub media type. If they are the same, the one with the more parameters has a higher priority. Otherwise the least specific has the lower priority, otherwise they have the same priority.

Attributes