Safe Haskell | None |
---|---|
Language | Haskell98 |
- data Api m where
- Unversioned :: Some1 (Router m) -> Api m
- Versioned :: VersionSet m -> Api m
- type VersionSet m = [(Version, Some1 (Router m))]
- data Router m s where
- data Some1 f where
- route :: Monad s => Resource m s sid mid aid -> Router m s
- compose :: Router m s -> Router s t -> Router m s
- (-/) :: Router m s -> Router s t -> Router m s
- (--/) :: Router m s -> Router s t -> Router m s
- (---/) :: Router m s -> Router s t -> Router m s
- (----/) :: Router m s -> Router s t -> Router m s
- (-----/) :: Router m s -> Router s t -> Router m s
- (------/) :: Router m s -> Router s t -> Router m s
- root :: (Applicative m, Monad m) => Router m m
- data Version = Version {}
- mkVersion :: Int -> Int -> Int -> Version
- latest :: VersionSet m -> Maybe (Version, Some1 (Router m))
- parseVersion :: String -> Maybe Version
- lookupVersion :: String -> VersionSet m -> Maybe (Some1 (Router m))
- lookupVersion' :: Version -> VersionSet m -> Maybe (Some1 (Router m))
- withVersion :: String -> Api m -> r -> (Version -> Some1 (Router m) -> r) -> r
Api data types.
An API can be versioned or unversioned. A versioned API is a set of versioned routers. An unversioned API is just a single router.
Unversioned :: Some1 (Router m) -> Api m | |
Versioned :: VersionSet m -> Api m |
type VersionSet m = [(Version, Some1 (Router m))] Source #
A version set is a list of versioned routers.
An existential where the second argument has kind (* -> *)
.
Defining routes.
route :: Monad s => Resource m s sid mid aid -> Router m s Source #
Convenience constructor constructing a route without any subresource.
compose :: Router m s -> Router s t -> Router m s Source #
Add the second router as a subresource to the first.
(-/) :: Router m s -> Router s t -> Router m s infixl 4 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(--/) :: Router m s -> Router s t -> Router m s infixl 5 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(---/) :: Router m s -> Router s t -> Router m s infixl 6 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(----/) :: Router m s -> Router s t -> Router m s infixl 7 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(-----/) :: Router m s -> Router s t -> Router m s infixl 8 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
(------/) :: Router m s -> Router s t -> Router m s infixl 9 Source #
Operators with the right fixities to allow you to define routes without using parentheses. Start with the shortest near the root.
root :: (Applicative m, Monad m) => Router m m Source #
An empty router to use as the root for your API.
Api versioning.
An API version has three parts. The first is two are used for API breaking changes, the last for non-API breaking changes.
latest :: VersionSet m -> Maybe (Version, Some1 (Router m)) Source #
Get the latest version of an API.
lookupVersion :: String -> VersionSet m -> Maybe (Some1 (Router m)) Source #
Look up a version in an API. The string can either be a valid
version according to parseVersion
, or "latest".
lookupVersion' :: Version -> VersionSet m -> Maybe (Some1 (Router m)) Source #
Look up a version in the API.