Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
include/ | H | 09-Sep-2001 | - | 9 | 8 | |
src/Web/ | H | 03-May-2022 | - | 1,691 | 707 | |
test/ | H | 09-Sep-2001 | - | 263 | 194 | |
CHANGELOG.md | H A D | 09-Sep-2001 | 4.2 KiB | 152 | 108 | |
LICENSE | H A D | 09-Sep-2001 | 1.3 KiB | 26 | 20 | |
README.md | H A D | 09-Sep-2001 | 1.4 KiB | 58 | 43 | |
Setup.hs | H A D | 09-Sep-2001 | 46 | 3 | 2 | |
http-api-data.cabal | H A D | 03-May-2022 | 3.6 KiB | 121 | 104 |
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