Safe Haskell | None |
---|
- type Api 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 :: Api m -> Maybe (Version, Some1 (Router m))
- parseVersion :: String -> Maybe Version
- lookupVersion :: String -> Api m -> Maybe (Some1 (Router m))
- lookupVersion' :: Version -> Api m -> Maybe (Some1 (Router m))
- withVersion :: String -> Api m -> r -> (Version -> Some1 (Router m) -> r) -> r
Api data types.
An existential where the second argument has kind (* -> *)
.
Defining routes.
route :: Monad s => Resource m s sid mid aid -> Router m sSource
Convenience constructor constructing a route without any subresource.
compose :: Router m s -> Router s t -> Router m sSource
Add the second router as a subresource to the first.
(-/) :: Router m s -> Router s t -> Router m sSource
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 sSource
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 sSource
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 sSource
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 sSource
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 sSource
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 mSource
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.
parseVersion :: String -> Maybe VersionSource
lookupVersion :: String -> Api 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.