jackfranklin/elm-parse-link-header/1.1.0

NOTE: this package is not compatible with Elm 0.19.1

LinkHeader

This library provides the ability to parse Link headers returned from APIs.

Types

type LinkRel
= RelNext Int
| RelPrev Int
| RelFirst Int
| RelLast Int
| RelUnknown Int

The possible types of web links that this parser might produce.

Parsing

parse : String -> List WebLink

Parse is given the string, which should be the entire link header from your API and returns a list of WebLinks. This will be empty if no matches were found. parse "https://api.github.com/user/193238/repos?per_page=100&page=2; rel="next"" == [WebLink (RelNext 2) "https://api.github.com/user/193238/repos?per_page=100&page=2"]

Reading results

webLinkIsNext : WebLink -> Bool

Tells you if a given WebLink is the next link.

webLinkIsPrev : WebLink -> Bool

Tells you if a given WebLink is the prev link.

webLinkIsFirst : WebLink -> Bool

Tells you if a given WebLink is first.

webLinkIsLast : WebLink -> Bool

Tells you if a given WebLink is last.

getIntegerForRel : LinkRel -> Int

Takes a LinkRel and finds the number for the page getIntegerForRel (RelPrev 2) == 2