Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Newtype wrappers for route DSL
Synopsis
- newtype Body media a = Body a
- newtype Query (sym :: Symbol) a = Query a
- newtype QueryFlag (sym :: Symbol) = QueryFlag Bool
- newtype Optional (sym :: Symbol) a = Optional (Maybe a)
- newtype Capture (sym :: Symbol) a = Capture a
- newtype Header (sym :: Symbol) a = Header a
- newtype OptionalHeader (sym :: Symbol) a = OptionalHeader (Maybe a)
- newtype Cookie a = Cookie (Maybe a)
- newtype PathInfo = PathInfo [Text]
- newtype FullPathInfo = FullPathInfo Text
- newtype RawRequest = RawRequest Request
- newtype IsSecure = IsSecure Bool
- newtype Send method m a = Send {
- unSend :: m a
- type Get m a = Send GET m a
- type Post m a = Send POST m a
- type Put m a = Send PUT m a
- type Delete m a = Send DELETE m a
- type Options m a = Send OPTIONS m a
- type Head m a = Send HEAD m a
- type Patch m a = Send PATCH m a
- type Trace m a = Send TRACE m a
- class IsMethod a where
- data GET
- data POST
- data PUT
- data DELETE
- data OPTIONS
- data HEAD
- data PATCH
- data TRACE
inputs
Generic case for request body. The type encodes a media type and value of the request body.
Body a |
Instances
(FromReqBody ty a, ToSchema a, ToPlugin b) => ToPlugin (Body ty a -> b) Source # | |
(ToSchema a, FromReqBody media a, ToRoute b) => ToRoute (Body media a -> b) Source # | |
Defined in Mig.Core.Class.Route |
newtype Query (sym :: Symbol) a Source #
Required URL parameter query.
"api/route?foo=bar" ==> (Query bar) :: Query "foo" a
Query a |
Instances
(FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Query sym a -> b) Source # | |
(FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Query sym a -> b) Source # | |
Defined in Mig.Core.Class.Route | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Query sym a -> b) Source # | |
newtype QueryFlag (sym :: Symbol) Source #
Query flag. It is a boolean value in the URL-query. If it is missing
it is False
if it is in the query but does not have any value it is True
.
Also it can have values true/false
in the query.
Instances
(ToPlugin b, KnownSymbol sym) => ToPlugin (QueryFlag sym -> b) Source # | |
(ToRoute b, KnownSymbol sym) => ToRoute (QueryFlag sym -> b) Source # | |
Defined in Mig.Core.Class.Route | |
(KnownSymbol sym, ToUrl b) => ToUrl (QueryFlag sym -> b) Source # | |
newtype Optional (sym :: Symbol) a Source #
Optional URL parameter query.
"api/route?foo=bar" ==> (Optional maybeBar) :: Query "foo" a
Instances
(FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Optional sym a -> b) Source # | |
(FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Optional sym a -> b) Source # | |
Defined in Mig.Core.Class.Route | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Optional sym a -> b) Source # | |
newtype Capture (sym :: Symbol) a Source #
Argument of capture from the query.
"api/route/{foo} if api/route/bar passed" ==> (Capture bar) :: Capture "Foo" barType
Capture a |
Instances
(FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Capture sym a -> b) Source # | |
(FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Capture sym a -> b) Source # | |
Defined in Mig.Core.Class.Route | |
(KnownSymbol sym, ToHttpApiData a, ToUrl b) => ToUrl (Capture sym a -> b) Source # | |
newtype Header (sym :: Symbol) a Source #
Reads value from the required header by name. For example if the request has header:
"foo": "bar"
It reads the value:
(Header bar) :: Header "foo" barType
Header a |
Instances
(FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (Header sym a -> b) Source # | |
(FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (Header sym a -> b) Source # | |
Defined in Mig.Core.Class.Route |
newtype OptionalHeader (sym :: Symbol) a Source #
Reads value from the optional header by name. For example if the request has header:
"foo": "bar"
It reads the value:
(OptionalHeader (Just bar)) :: OptionalHeader "foo" barType
OptionalHeader (Maybe a) |
Instances
(FromHttpApiData a, ToParamSchema a, ToPlugin b, KnownSymbol sym) => ToPlugin (OptionalHeader sym a -> b) Source # | |
Defined in Mig.Core.Class.Plugin toPluginInfo :: RouteInfo -> RouteInfo Source # toPluginFun :: (OptionalHeader sym a -> b) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) Source # | |
(FromHttpApiData a, ToParamSchema a, ToRoute b, KnownSymbol sym) => ToRoute (OptionalHeader sym a -> b) Source # | |
Defined in Mig.Core.Class.Route toRouteInfo :: RouteInfo -> RouteInfo Source # toRouteFun :: (OptionalHeader sym a -> b) -> ServerFun (MonadOf (OptionalHeader sym a -> b)) Source # |
Reads a cookie. It's an optional header with name Cookie. The cookie is URL-encoded and read with instnace of FromForm class.
data MyCookie = MyCookie { secret :: Text , count :: Int } deriving (Generic, FromForm) > "secret=lolkek&count=101" (Cookie (Just (MyCookie { secret = "lolkek", count = 101 }))) :: Cookie MyCookie
Reads current path info.
"api/foo/bar" ==> PathInfo ["foo", "bar"]
newtype FullPathInfo Source #
Reads current full-path info with queries.
"api/foo/bar?param=value" ==> FullPathInfo "api/foo/bar?param=value"
Instances
ToPlugin a => ToPlugin (FullPathInfo -> a) Source # | |
Defined in Mig.Core.Class.Plugin toPluginInfo :: RouteInfo -> RouteInfo Source # toPluginFun :: (FullPathInfo -> a) -> ServerFun (MonadOf (FullPathInfo -> a)) -> ServerFun (MonadOf (FullPathInfo -> a)) Source # | |
ToRoute b => ToRoute (FullPathInfo -> b) Source # | |
Defined in Mig.Core.Class.Route toRouteInfo :: RouteInfo -> RouteInfo Source # toRouteFun :: (FullPathInfo -> b) -> ServerFun (MonadOf (FullPathInfo -> b)) Source # |
newtype RawRequest Source #
Read low-level request. Note that it does not affect the API schema
Instances
ToPlugin a => ToPlugin (RawRequest -> a) Source # | |
Defined in Mig.Core.Class.Plugin toPluginInfo :: RouteInfo -> RouteInfo Source # toPluginFun :: (RawRequest -> a) -> ServerFun (MonadOf (RawRequest -> a)) -> ServerFun (MonadOf (RawRequest -> a)) Source # | |
ToRoute b => ToRoute (RawRequest -> b) Source # | |
Defined in Mig.Core.Class.Route toRouteInfo :: RouteInfo -> RouteInfo Source # toRouteFun :: (RawRequest -> b) -> ServerFun (MonadOf (RawRequest -> b)) Source # |
Reads info on weather the connection is secure (made over SSL).
outputs
newtype Send method m a Source #
Route response type. It encodes the route method in the type and which monad is used and which type the response has.
The repsonse value is usually one of two cases:
Resp media a
-- for routes which always produce a valueRespOr media err a
- for routes that can also produce an error or value.
See the class IsResp
for more details on response types.
Instances
MonadTrans (Send method :: (Type -> Type) -> Type -> Type) Source # | |
Defined in Mig.Core.Types.Route | |
MonadIO m => MonadIO (Send method m) Source # | |
Defined in Mig.Core.Types.Route | |
Applicative m => Applicative (Send method m) Source # | |
Defined in Mig.Core.Types.Route pure :: a -> Send method m a # (<*>) :: Send method m (a -> b) -> Send method m a -> Send method m b # liftA2 :: (a -> b -> c) -> Send method m a -> Send method m b -> Send method m c # (*>) :: Send method m a -> Send method m b -> Send method m b # (<*) :: Send method m a -> Send method m b -> Send method m a # | |
Functor m => Functor (Send method m) Source # | |
Monad m => Monad (Send method m) Source # | |
(MonadIO m, IsResp a, IsMethod method) => ToRoute (Send method m a) Source # | |
Defined in Mig.Core.Class.Route |
Method tags
class IsMethod a where Source #
Converts type-level tag for methods to value
Instances
IsMethod DELETE Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod GET Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod HEAD Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod OPTIONS Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod PATCH Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod POST Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod PUT Source # | |
Defined in Mig.Core.Types.Route | |
IsMethod TRACE Source # | |
Defined in Mig.Core.Types.Route |
type-level GET-method tag
type-level POST-method tag
type-level PUT-method tag
type-level DELETE-method tag
type-level OPTIONS-method tag
type-level HEAD-method tag
type-level PATCH-method tag