git.iko.soy/typeable/servant-reflex
on develop help sign in
44 lines 1.4 kB history raw
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE TypeOperators #-}
4module API where
6import Data.Text (Text)
7import Servant.API
9-- | API spec for server, client, and docs
10type API = "getunit" :> Get '[JSON] ()
11 :<|> "getint" :> Get '[JSON] Int
12 :<|> "sayhi" :> QueryParam "username" Text
13 :> QueryParams "greetings" Text
14 :> QueryFlag "gusto"
15 :> Get '[JSON] Text
16 :<|> "double" :> ReqBody '[JSON] Double
17 :> Post '[JSON] Double
18 :<|> "a" :> "b" :> QueryFlag "gusto" :> Get '[JSON] Text
19 :<|> Raw
21type GET = Get '[JSON] ()
23-- Imported the comprehensive API example for testing.
24-- https://github.com/haskell-servant/servant/blob/master/servant/src/Servant/API/Internal/Test/ComprehensiveAPI.hs
25type ComprehensiveAPI =
26 GET :<|>
27 Get '[JSON] Int :<|>
28 Capture "foo" Int :> GET :<|>
29 Header "foo" Int :> GET :<|>
30 HttpVersion :> GET :<|>
31 IsSecure :> GET :<|>
32 QueryParam "foo" Int :> GET :<|>
33 QueryParams "foo" Int :> GET :<|>
34 QueryFlag "foo" :> GET :<|>
35-- Raw :<|>
36 RemoteHost :> GET :<|>
37 ReqBody '[JSON] Int :> GET :<|>
38 Get '[JSON] (Headers '[Header "foo" Int] ()) :<|>
39 "foo" :> GET :<|>
40 Vault :> GET :<|>
41 Verb 'POST 204 '[JSON] () :<|>
42 Verb 'POST 204 '[JSON] Int
43-- This one isn't in scope
44-- :<|> WithNamedContext "foo" '[] GET