http-api-data: Converting to/from HTTP API data like URL pieces, headers and query parameters.

[ bsd3, library, web ] [ Propose Tags ]

Please see README.md


[Skip to Readme]
Versions [faq] 0.1.0, 0.1.1, 0.1.1.1, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.7.1, 0.3.7.2, 0.3.8, 0.3.8.1, 0.3.9, 0.3.10, 0.4, 0.4.1 (info)
Change log CHANGELOG.md
Dependencies base (>=4.6 && <4.10), bytestring, text (>=0.5), text-show (>=2), time [details]
License BSD-3-Clause
Author Michael Snoyman <michael@snoyman.com>
Maintainer Nickolay Kudasov <nickolay.kudasov@gmail.com>
Revised Revision 1 made by phadej at Mon Mar 21 10:28:47 UTC 2016
Category Web
Home page http://github.com/fizruk/http-api-data
Source repo head: git clone https://github.com/fizruk/http-api-data
Uploaded by NickolayKudasov at Wed Oct 7 20:54:53 UTC 2015
Distributions Arch:0.4.1, Debian:0.3.8.1, Fedora:0.3.8.1, LTSHaskell:0.4, NixOS:0.4.1, Stackage:0.4, openSUSE:0.4.1
Downloads 28588 total (1014 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-10-14 [all 1 reports]

Modules

[Index]

Flags

NameDescriptionDefaultType
use-text-show

Use text-show library for efficient ToHttpApiData implementations.

DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for http-api-data-0.1.1

[back to package description]

http-api-data

Hackage package Build Status

This package defines typeclasses used for converting Haskell data types to and from HTTP API data.

Examples

Booleans:

>>> toUrlPiece True
"True"
>>> parseUrlPiece "False" :: Either Text Bool
Right False
>>> parseUrlPiece "something else" :: Either Text Bool
Left "could not parse: `something else'"

Numbers:

>>> toUrlPiece 45.2
"45.2"
>>> parseUrlPiece "452" :: Either Text Int
Right 452
>>> parseUrlPiece "256" :: Either Text Int8
Left "out of bounds: `256' (should be between -128 and 127)"

Strings:

>>> toHeader "hello"
"hello"
>>> parseHeader "world" :: Either Text String
Right "world"

Calendar day:

>>> toQueryParam (fromGregorian 2015 10 03)
"2015-10-03"
>>> toGregorian <$> parseQueryParam "2016-12-01"
Right (2016,12,1)

Contributing

Contributions and bug reports are welcome!