| Copyright | (C) 2016-2018 David M. Johnson |
|---|---|
| License | BSD3-style (see the file LICENSE) |
| Maintainer | David M. Johnson <djohnson.m@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Router
Description
Documentation
runRoute :: HasRouter layout => Proxy layout -> RouteT layout (m -> a) -> (m -> URI) -> m -> Either RoutingError a Source #
route :: HasRouter layout => Proxy layout -> RouteT layout a -> URI -> Either RoutingError a Source #
Use a handler to mkRouter a location, represented as a String.
All handlers must, in the end, return m a.
routeLoc will choose a mkRouter and return its result.
class HasRouter layout Source #
This is similar to the HasServer class from servant-server.
It is the class responsible for making API combinators routable.
RouteT is used to build up the handler types.
Router is returned, to be interpretted by routeLoc.
Minimal complete definition
mkRouter
Instances
| HasRouter Raw Source # | Raw |
| HasRouter (View a :: Type) Source # | View |
| (HasRouter x, HasRouter y) => HasRouter (x :<|> y :: Type) Source # | Alternative |
| (HasRouter sublayout, FromHttpApiData x, KnownSymbol sym) => HasRouter (QueryParam sym x :> sublayout :: Type) Source # | QueryParam |
Defined in Miso.Router Methods mkRouter :: Proxy (QueryParam sym x :> sublayout) -> Proxy a -> RouteT (QueryParam sym x :> sublayout) a -> Router a | |
| (HasRouter sublayout, FromHttpApiData x, KnownSymbol sym) => HasRouter (QueryParams sym x :> sublayout :: Type) Source # | QueryParams |
Defined in Miso.Router Methods mkRouter :: Proxy (QueryParams sym x :> sublayout) -> Proxy a -> RouteT (QueryParams sym x :> sublayout) a -> Router a | |
| (HasRouter sublayout, KnownSymbol sym) => HasRouter (QueryFlag sym :> sublayout :: Type) Source # | QueryFlag |
| HasRouter sublayout => HasRouter (Header sym x :> sublayout :: Type) Source # | Header |
| (HasRouter sublayout, FromHttpApiData x) => HasRouter (Capture sym x :> sublayout :: Type) Source # | Capture |
| (HasRouter sublayout, KnownSymbol path) => HasRouter (path :> sublayout :: Type) Source # | Path |
| HasRouter (Verb m s c a :: Type) Source # | Verb |
type family RouteT layout a :: * Source #
A mkRouter handler.
Instances
| type RouteT Raw x Source # | |
Defined in Miso.Router | |
| type RouteT (View a :: Type) x Source # | |
Defined in Miso.Router | |
| type RouteT (x :<|> y :: Type) a Source # | |
| type RouteT (QueryParam sym x :> sublayout :: Type) a Source # | |
Defined in Miso.Router | |
| type RouteT (QueryParams sym x :> sublayout :: Type) a Source # | |
Defined in Miso.Router | |
| type RouteT (QueryFlag sym :> sublayout :: Type) a Source # | |
| type RouteT (Header sym x :> sublayout :: Type) a Source # | |
| type RouteT (Capture sym x :> sublayout :: Type) a Source # | |
| type RouteT (path :> sublayout :: Type) a Source # | |
Defined in Miso.Router | |
| type RouteT (Verb m s c a :: Type) x Source # | |
Defined in Miso.Router | |
data RoutingError Source #
When routing, the router may fail to match a location.
Constructors
| Fail |
Instances
| Eq RoutingError Source # | |
Defined in Miso.Router | |
| Ord RoutingError Source # | |
Defined in Miso.Router Methods compare :: RoutingError -> RoutingError -> Ordering # (<) :: RoutingError -> RoutingError -> Bool # (<=) :: RoutingError -> RoutingError -> Bool # (>) :: RoutingError -> RoutingError -> Bool # (>=) :: RoutingError -> RoutingError -> Bool # max :: RoutingError -> RoutingError -> RoutingError # min :: RoutingError -> RoutingError -> RoutingError # | |
| Show RoutingError Source # | |
Defined in Miso.Router Methods showsPrec :: Int -> RoutingError -> ShowS # show :: RoutingError -> String # showList :: [RoutingError] -> ShowS # | |