api-builder-0.1.0.1: Library for easily building REST API wrappers in Haskell

Safe HaskellNone

APIBuilder.Routes

Synopsis

Documentation

data Route Source

Main type for routes in the API. Used to represent the URL minus the actual endpoint URL as well as the query string and the HTTP method used to communicate with the server.

Constructors

Route 

Instances

type URLFragment = TextSource

Alias for Text to store the URL fragments for each Route.

type URLParam = (Text, Maybe Text)Source

Alias to (Text, Maybe Text) used to store each query that gets tacked onto the request.

(=.) :: Text -> Maybe Text -> (Text, Maybe Text)Source

Convenience function for building URLParams.

>>> "api_type" =. Just "json"
("api_type", Just "json")

data HTTPMethod Source

Type for different HTTP request methods. Has the two most common ones (GET and POST) as well as support for custom methods.

Constructors

GET 
POST 
CustomMethod Text 

showMethod :: HTTPMethod -> StringSource

Get a String from a HTTPMethod. Used mostly for creating Requests.

>>> showMethod GET
"GET"
>>> showMethod (CustomMethod "PATCH")
"PATCH"

routeURLSource

Arguments

:: Text

base URL for the Route (you can usually get this from the Builder)

-> Route

the Route to process

-> Text

the finalized URL as a Text

Converts a Route to a URL. Drops any Nothing values from the query, separates the fragments with / and tacks them onto the end of the base URL.