Network.HTTP.Media.Accept

http-media-0.8.1.1: Processing HTTP Content-Type and Accept headers

Safe Haskell | Safe-Inferred
Language | Haskell2010

Network.HTTP.Media.Accept

Description

Defines the `Accept` type class, designed to unify types on the matching functions in the Media module.

Synopsis

- class Show a => Accept a where
  - parseAccept :: ByteString -> Maybe a
  - matches :: a -> a -> Bool
  - moreSpecificThan :: a -> a -> Bool
  - hasExtensionParameters :: Proxy a -> Bool

# Documentation

class Show a => Accept a where #

Defines methods for a type whose values can be matched against each other in terms of an HTTP Accept-* header.

This allows functions to work on both the standard Accept header and others such as Accept-Language that still may use quality values.

Minimal complete definition

parseAccept, matches, moreSpecificThan

Methods

parseAccept :: ByteString -> Maybe a #

Specifies how to parse an Accept-* header after quality has been handled.

matches :: a -> a -> Bool #

Evaluates whether either the left argument matches the right one.

This relation must be a total order, where more specific terms on the left can produce a match, but a less specific term on the left can never produce a match. For instance, when matching against media types it is important that if the client asks for a general type then we can choose a more specific offering from the server, but if a client asks for a specific type and the server only offers a more general form, then we cannot generalise. In this case, the server types will be the left argument, and the client types the right.

For types with no concept of specificity, this operation is just equality.

moreSpecificThan :: a -> a -> Bool #

Evaluates whether the left argument is more specific than the right.

This relation must be irreflexive and transitive. For types with no concept of specificity, this is the empty relation (always false).

hasExtensionParameters :: Proxy a -> Bool #

Indicates whether extension parameters are permitted after the weight parameter when this type appears in an Accept header. Defaults to false.

#### Instances

Instances details

Accept ByteString # |
Instance details Defined in Network.HTTP.Media.Accept Methods parseAccept :: ByteString -> Maybe ByteString # matches :: ByteString -> ByteString -> Bool # moreSpecificThan :: ByteString -> ByteString -> Bool # hasExtensionParameters :: Proxy ByteString -> Bool #
Accept Charset # |
Instance details Defined in Network.HTTP.Media.Charset.Internal Methods parseAccept :: ByteString -> Maybe Charset # matches :: Charset -> Charset -> Bool # moreSpecificThan :: Charset -> Charset -> Bool # hasExtensionParameters :: Proxy Charset -> Bool #
Accept Encoding # |
Instance details Defined in Network.HTTP.Media.Encoding.Internal Methods parseAccept :: ByteString -> Maybe Encoding # matches :: Encoding -> Encoding -> Bool # moreSpecificThan :: Encoding -> Encoding -> Bool # hasExtensionParameters :: Proxy Encoding -> Bool #
Accept Language # |
Instance details Defined in Network.HTTP.Media.Language.Internal Methods parseAccept :: ByteString -> Maybe Language # matches :: Language -> Language -> Bool # moreSpecificThan :: Language -> Language -> Bool # hasExtensionParameters :: Proxy Language -> Bool #
Accept MediaType # |
Instance details Defined in Network.HTTP.Media.MediaType.Internal Methods parseAccept :: ByteString -> Maybe MediaType # matches :: MediaType -> MediaType -> Bool # moreSpecificThan :: MediaType -> MediaType -> Bool # hasExtensionParameters :: Proxy MediaType -> Bool #