@hackage http-link-header1.2.3
HTTP Link header parser/writer
Categories
License
LicenseRef-PublicDomain
Maintainer
val@packett.cool
Links
Versions
Installation
Dependencies (7)
- attoparsec
- base >=4.3 && <5
- bytestring
- errors
- http-api-data
- network-uri Show all…
Dependents (8)
@hackage/freckle-app, @hackage/freckle-http, @hackage/yesod-page-cursor, @hackage/github, @hackage/acme-everything, @hackage/indieweb-algorithms, Show all…
http-link-header
A Haskell library than implements a parser and a writer for the HTTP Link header as specified in RFC 5988 "Web Linking".
Usage
import Network.HTTP.Link
import Network.URI
import Data.Maybe
----- Writing
writeLinkHeader [ Link (fromJust $ parseURI "https://example.com/hello%20world") [(Rel, "next"), (Title, "hello world")]
, Link (fromJust $ parseURI "https://yolo.tld") [(Rel, "license")] ]
-- "<https://example.com/hello%20world>; rel=\"next\"; title=\"hello world\", <https://yolo.tld>; rel=\"license\""
----- Parsing
parseLinkHeader "<https://example.com/2>; rel=\"next\", <https://example.com/0>; rel=prev"
-- Just [ Link https://example.com/2 [(Rel, "next")]
-- , Link https://example.com/0 [(Rel, "prev")] ]
Development
Use stack to build.
Use ghci to run tests quickly with :test (see the .ghci file).
$ stack build
$ stack test && rm tests.tix
$ stack bench
$ stack ghci --ghc-options="-fno-hpc"
License
This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.