• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

include/H09-Sep-2001-98

src/Web/H03-May-2022-1,691707

test/H09-Sep-2001-263194

CHANGELOG.mdH A D09-Sep-20014.2 KiB152108

LICENSEH A D09-Sep-20011.3 KiB2620

README.mdH A D09-Sep-20011.4 KiB5843

Setup.hsH A D09-Sep-200146 32

http-api-data.cabalH A D03-May-20223.6 KiB121104

README.md

1# http-api-data
2
3[![Build Status](https://secure.travis-ci.org/fizruk/http-api-data.png?branch=master)](http://travis-ci.org/fizruk/http-api-data)
4[![Hackage package](http://img.shields.io/hackage/v/http-api-data.svg)](http://hackage.haskell.org/package/http-api-data)
5[![Stackage LTS](http://stackage.org/package/http-api-data/badge/lts)](http://stackage.org/lts/package/http-api-data)
6[![Stackage Nightly](http://stackage.org/package/http-api-data/badge/nightly)](http://stackage.org/nightly/package/http-api-data)
7
8This package defines typeclasses used for converting Haskell data types to and from HTTP API data.
9
10### Examples
11
12Booleans:
13
14```
15>>> toUrlPiece True
16"true"
17>>> parseUrlPiece "false" :: Either Text Bool
18Right False
19>>> parseUrlPieces ["true", "false", "undefined"] :: Either Text [Bool]
20Left "could not parse: `undefined'"
21```
22
23Numbers:
24
25```
26>>> toQueryParam 45.2
27"45.2"
28>>> parseQueryParam "452" :: Either Text Int
29Right 452
30>>> toQueryParams [1..5]
31["1","2","3","4","5"]
32>>> parseQueryParams ["127", "255"] :: Either Text [Int8]
33Left "out of bounds: `255' (should be between -128 and 127)"
34```
35
36Strings:
37
38```
39>>> toHeader "hello"
40"hello"
41>>> parseHeader "world" :: Either Text String
42Right "world"
43```
44
45Calendar day:
46
47```
48>>> toQueryParam (fromGregorian 2015 10 03)
49"2015-10-03"
50>>> toGregorian <$> parseQueryParam "2016-12-01"
51Right (2016,12,1)
52```
53
54## Contributing
55
56Contributions and bug reports are welcome!
57
58