git.iko.soy/purestack-dev/purescript-purestack-server
on master help sign in
55 lines 1.4 kB history raw
1module PureStack.Route
2 ( type (/)
3 , Slash
4 , HttpMethod
5 , class MethodName
6 , methodName
7 , GET
8 , POST
9 , PUT
10 , DELETE
11 , PATCH
12 , Headers(..)
13 , Middleware
14 ) where
16data HttpMethod
18-- | The `req` can only ever be `Unit`
19foreign import data GET :: Type -> Type -> HttpMethod
20foreign import data POST :: Type -> Type -> HttpMethod
21foreign import data PUT :: Type -> Type -> HttpMethod
22foreign import data DELETE :: Type -> Type -> HttpMethod
23foreign import data PATCH :: Type -> Type -> HttpMethod
25class MethodName :: HttpMethod -> Constraint
26class MethodName method where
27 methodName :: String
29instance MethodName (GET req resp) where
30 methodName = "GET"
32instance MethodName (POST req resp) where
33 methodName = "POST"
35instance MethodName (PUT req resp) where
36 methodName = "PUT"
38instance MethodName (DELETE req resp) where
39 methodName = "DELETE"
41instance MethodName (PATCH req resp) where
42 methodName = "PATCH"
44data Slash :: forall k1 k2. k1 -> k2 -> Type
45data Slash x y
47-- | Operator for separating path pieces when specisying APIs.
48-- | `Symbol`s are treated as constant path pieces.
49-- | `Record`s are treated as query parameters. `Array`s are lists, `Maybe`s are optional query parameters.
50-- | Other types are captured path pieces.
51infixr 1 type Slash as /
53data Headers headers r = Headers headers r
55data Middleware tag