@@ -18,7 +18,7 @@ import Servant.API
18-- Types for testing
18-- Types for testing
19--------------------------------------------------------------------------
19--------------------------------------------------------------------------
21−
21+-- Methods ---------------------------------------------------------------
22type SimpleGet = [sitemap|
22type SimpleGet = [sitemap|
23GET hello ()
23GET hello ()
@@ -43,12 +43,47 @@ POST hello Bool
43type SimplePost2' = "hello" :> Post Bool
43type SimplePost2' = "hello" :> Post Bool
44type SimplePost2'' = "hello" :> Post ()
44type SimplePost2'' = "hello" :> Post ()
46+type SimplePut = [sitemap|
49+type SimplePut' = "hello" :> Put ()
50+type SimplePut'' = "hello" :> Put Bool
52+type SimplePut2 = [sitemap|
55+type SimplePut2' = "hello" :> Put Bool
56+type SimplePut2'' = "hello" :> Put ()
58+-- Parameters ------------------------------------------------------------
46type SimpleReqBody = [sitemap|
60type SimpleReqBody = [sitemap|
47POST hello () -> Bool
61POST hello () -> Bool
49type SimpleReqBody' = "hello" :> ReqBody () :> Post Bool
63type SimpleReqBody' = "hello" :> ReqBody () :> Post Bool
50type SimpleReqBody'' = "hello" :> ReqBody Bool :> Post ()
64type SimpleReqBody'' = "hello" :> ReqBody Bool :> Post ()
66+type SimpleCapture = [sitemap|
69+type SimpleCapture' = "hello" :> Capture "p" Int :> Post Bool
70+type SimpleCapture'' = "hello" :> Capture "r" Int :> Post Bool
71+type SimpleCapture''' = "hello" :> Capture "p" Bool :> Post Bool
73+type SimpleQueryParam = [sitemap|
74+POST hello/?p:Int Bool
76+type SimpleQueryParam' = "hello" :> QueryParam "p" Int :> Post Bool
77+type SimpleQueryParam'' = "hello" :> QueryParam "r" Int :> Post Bool
78+type SimpleQueryParam''' = "hello" :> QueryParam "p" Bool :> Post Bool
80+-- Combinations ----------------------------------------------------------
82+type TwoPaths = [sitemap|
86+type TwoPaths' = ("hello" :> Post Bool) :<|> ("hello" :> Get Bool)
52--------------------------------------------------------------------------
87--------------------------------------------------------------------------
54--------------------------------------------------------------------------
89--------------------------------------------------------------------------
@@ -66,9 +101,24 @@ spec = do
66 (u::SimplePost) ~= (u::SimplePost'' ) ~> False
101 (u::SimplePost) ~= (u::SimplePost'' ) ~> False
67 (u::SimplePost2) ~= (u::SimplePost2' ) ~> True
102 (u::SimplePost2) ~= (u::SimplePost2' ) ~> True
68 (u::SimplePost2) ~= (u::SimplePost2'') ~> False
103 (u::SimplePost2) ~= (u::SimplePost2'') ~> False
104+ it "Handles simple PUT types" $ do
105+ (u::SimplePut) ~= (u::SimplePut' ) ~> True
106+ (u::SimplePut) ~= (u::SimplePut'' ) ~> False
107+ (u::SimplePut2) ~= (u::SimplePut2' ) ~> True
108+ (u::SimplePut2) ~= (u::SimplePut2'') ~> False
69 it "Handles simple request body types" $ do
109 it "Handles simple request body types" $ do
70 (u::SimpleReqBody) ~= (u::SimpleReqBody' ) ~> True
110 (u::SimpleReqBody) ~= (u::SimpleReqBody' ) ~> True
71 (u::SimpleReqBody) ~= (u::SimpleReqBody'') ~> False
111 (u::SimpleReqBody) ~= (u::SimpleReqBody'') ~> False
112+ it "Handles simple captures" $ do
113+ (u::SimpleCapture) ~= (u::SimpleCapture' ) ~> True
114+ (u::SimpleCapture) ~= (u::SimpleCapture'') ~> False
115+ (u::SimpleCapture) ~= (u::SimpleCapture''') ~> False
116+ it "Handles simple querystring parameters" $ do
117+ (u::SimpleQueryParam) ~= (u::SimpleQueryParam' ) ~> True
118+ (u::SimpleQueryParam) ~= (u::SimpleQueryParam'') ~> False
119+ (u::SimpleQueryParam) ~= (u::SimpleQueryParam''') ~> False
120+ it "Handles multiples paths" $ do
121+ (u::TwoPaths) ~= (u::TwoPaths') ~> True
74--------------------------------------------------------------------------
124--------------------------------------------------------------------------