summaryrefslogtreecommitdiff
path: root/dev-haskell/http-media/metadata.xml
blob: 218cc2160eb0e59bf087d530425798da9f77ee34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
	<maintainer type="project">
		<email>haskell@gentoo.org</email>
		<name>Gentoo Haskell</name>
	</maintainer>
	<longdescription>
		This library is intended to be a comprehensive solution to parsing and
		selecting quality-indexed values in HTTP headers. It is capable of parsing
		both media types and language parameters from the Accept and Content header
		families, and can be extended to match against other accept headers as well.
		Selecting the appropriate header value is achieved by comparing a list of
		server options against the quality-indexed values supplied by the client.
		
		In the following example, the Accept header is parsed and then matched against
		a list of server options to serve the appropriate media using
		'mapAcceptMedia':
		
		&gt; getHeader &gt;&gt;= maybe send406Error sendResourceWith . mapAcceptMedia
		&gt;     [ ("text/html",        asHtml)
		&gt;     , ("application/json", asJson)
		&gt;     ]
		
		Similarly, the Content-Type header can be used to produce a parser for request
		bodies based on the given content type with 'mapContentMedia':
		
		&gt; getContentType &gt;&gt;= maybe send415Error readRequestBodyWith . mapContentMedia
		&gt;     [ ("application/json", parseJson)
		&gt;     , ("text/plain",       parseText)
		&gt;     ]
		
		The API is agnostic to your choice of server.
	</longdescription>
</pkgmetadata>