brian-watkins/elm-spec/2.0.0

NOTE: the latest version is 3.3.2

Spec.Http.Route

Functions for defining HTTP routes.

Represents an HTTP route.

Define a Route

get : String -> HttpRoute

Define a GET route with the given URL.

get "http://fun.com/fun"
post : String -> HttpRoute

Define a POST route with the given URL.

post "http://fun.com/fun"
= Exact String
| Matching String

Describe a URL when constructing a Route with the route function.

Use the Exact case when you want to provide a specific string to match against, for example, an absolute URL.

Use the Matching case when you want to provide a JavaScript-style regular expression to match against.

Define a route with the given method and url descriptor.

For example, this route describes any request with the protocol http and the method PATCH:

Spec.Http.Route.route "PATCH" <| Matching "http:\\/\\/.*"

Work with Routes

encode : HttpRoute -> Value

Encode an HttpRoute into a JSON object.

toString : HttpRoute -> String

Represent an HttpRoute as a string.