git.iko.soy/typeable/servant
on master help sign in
ReqBody content types.
a1e1de9Julian K. Arni
servant.cabal+16−3
@@ -47,13 +47,26 @@ library
47 base >=4.7 && <5
47 base >=4.7 && <5
48 , bytestring == 0.10.*
48 , bytestring == 0.10.*
49 , http-types == 0.8.*
49 , http-types == 0.8.*
50− , text >= 1
50+ , text >= 1 && < 2
51− , template-haskell
51+ , template-haskell >= 2.7 && < 2.10
52 , parsec >= 3.1
52 , parsec >= 3.1
53− , string-conversions >= 0.3
53+ , string-conversions >= 0.3 && < 0.4
54 , network-uri >= 2.6
54 , network-uri >= 2.6
55 hs-source-dirs: src
55 hs-source-dirs: src
56 default-language: Haskell2010
56 default-language: Haskell2010
57+ extensions: DataKinds
58+ , DeriveDataTypeable
59+ , FunctionalDependencies
60+ , KindSignatures
61+ , MultiParamTypeClasses
62+ , PolyKinds
63+ , QuasiQuotes
64+ , ScopedTypeVariables
65+ , TemplateHaskell
66+ , TypeFamilies
67+ , TypeOperators
68+ , UndecidableInstances
69+ , FlexibleInstances
57 ghc-options: -Wall
70 ghc-options: -Wall
58
71
59test-suite spec
72test-suite spec
src/Servant/API.hs+2−1
@@ -46,7 +46,8 @@ module Servant.API (
46
46
47import Servant.API.Alternative ( (:<|>)(..) )
47import Servant.API.Alternative ( (:<|>)(..) )
48import Servant.API.Capture ( Capture )
48import Servant.API.Capture ( Capture )
49−import Servant.API.ContentTypes ( HTML, XML, JSON, JavaScript, CSS, PlainText )
49+import Servant.API.ContentTypes ( HTML, XML, JSON, JavaScript, CSS
50+ , PlainText, OctetStream )
50import Servant.API.Delete ( Delete )
51import Servant.API.Delete ( Delete )
51import Servant.API.Get ( Get )
52import Servant.API.Get ( Get )
52import Servant.API.Header ( Header )
53import Servant.API.Header ( Header )
src/Servant/API/ContentTypes.hs+1
@@ -10,3 +10,4 @@ data JSON deriving Typeable
10data JavaScript deriving Typeable
10data JavaScript deriving Typeable
11data CSS deriving Typeable
11data CSS deriving Typeable
12data PlainText deriving Typeable
12data PlainText deriving Typeable
13+data OctetStream deriving Typeable
src/Servant/API/Raw.hs+3−1
@@ -1,5 +1,7 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
1module Servant.API.Raw where
2module Servant.API.Raw where
2
3
4+import Data.Typeable (Typeable)
3-- | Endpoint for plugging in your own Wai 'Application's.
5-- | Endpoint for plugging in your own Wai 'Application's.
4--
6--
5-- The given 'Application' will get the request as received by the server, potentially with
7-- The given 'Application' will get the request as received by the server, potentially with
@@ -9,4 +11,4 @@ module Servant.API.Raw where
9-- this can also be used with 'Servant.Utils.StaticFiles.serveDirectory' to serve
11-- this can also be used with 'Servant.Utils.StaticFiles.serveDirectory' to serve
10-- static files stored in a particular directory on your filesystem, or to serve
12-- static files stored in a particular directory on your filesystem, or to serve
11-- your API's documentation with 'Servant.Utils.StaticFiles.serveDocumentation'.
13-- your API's documentation with 'Servant.Utils.StaticFiles.serveDocumentation'.
12−data Raw
14+data Raw deriving Typeable
src/Servant/API/ReqBody.hs+3−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE PolyKinds #-}
2{-# LANGUAGE PolyKinds #-}
2module Servant.API.ReqBody where
3module Servant.API.ReqBody where
3
4
@@ -6,5 +7,5 @@ module Servant.API.ReqBody where
6-- Example:
7-- Example:
7--
8--
8-- > -- POST /books
9-- > -- POST /books
9−-- > type MyApi = "books" :> ReqBody Book :> Post Book
10+-- > type MyApi = "books" :> ReqBody '[JSON] Book :> Post Book
10−data ReqBody a
11+data ReqBody (ls::[*]) a
src/Servant/QQ.hs+2−2
@@ -1,7 +1,7 @@
1−{-# LANGUAGE MultiParamTypeClasses #-}
2−{-# LANGUAGE FunctionalDependencies #-}
3{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE FunctionalDependencies #-}
4+{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE ScopedTypeVariables #-}
5{-# LANGUAGE ScopedTypeVariables #-}
6{-# LANGUAGE TemplateHaskell #-}
6{-# LANGUAGE TemplateHaskell #-}
7{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
7{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
src/Servant/Utils/Links.hs+5−3
@@ -2,10 +2,11 @@
2{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE TypeFamilies #-}
6−{-# LANGUAGE TypeOperators #-}
7{-# LANGUAGE FunctionalDependencies #-}
5{-# LANGUAGE FunctionalDependencies #-}
6+{-# LANGUAGE PolyKinds #-}
8{-# LANGUAGE ScopedTypeVariables #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
9{-# LANGUAGE UndecidableInstances #-}
10{-# LANGUAGE UndecidableInstances #-}
10
11
11-- | Type safe generation of internal links.
12-- | Type safe generation of internal links.
@@ -155,7 +156,8 @@ type family IsElem endpoint api :: Constraint where
155 IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb)
156 IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb)
156 IsElem (e :> sa) (e :> sb) = IsElem sa sb
157 IsElem (e :> sa) (e :> sb) = IsElem sa sb
157 IsElem sa (Header x :> sb) = IsElem sa sb
158 IsElem sa (Header x :> sb) = IsElem sa sb
158− IsElem sa (ReqBody x :> sb) = IsElem sa sb
159+ IsElem sa (ReqBody y x :> sb) = IsElem sa sb
160+ IsElem (e :> sa) (Capture x y :> sb) = IsElem sa sb
159 IsElem sa (QueryParam x y :> sb) = IsElem sa sb
161 IsElem sa (QueryParam x y :> sb) = IsElem sa sb
160 IsElem sa (QueryParams x y :> sb) = IsElem sa sb
162 IsElem sa (QueryParams x y :> sb) = IsElem sa sb
161 IsElem sa (QueryFlag x :> sb) = IsElem sa sb
163 IsElem sa (QueryFlag x :> sb) = IsElem sa sb
test/Servant/Utils/LinksSpec.hs+2−3
@@ -12,7 +12,6 @@ import Servant.API ( type (:<|>), ReqBody, QueryParam, MatrixParam, MatrixParams
12 , MatrixFlag, Get, Post, Capture, type (:>) , HTML , JSON, XML )
12 , MatrixFlag, Get, Post, Capture, type (:>) , HTML , JSON, XML )
13import Servant.QQSpec ( (~>) )
13import Servant.QQSpec ( (~>) )
14import Servant.Utils.Links ( IsElem, IsLink )
14import Servant.Utils.Links ( IsElem, IsLink )
15−<<<<<<< HEAD
16
15
17type TestApi =
16type TestApi =
18 -- Capture and query/matrix params
17 -- Capture and query/matrix params
@@ -28,7 +27,7 @@ type TestApi =
28 -- All of the verbs
27 -- All of the verbs
29 :<|> "get" :> Get '[JSON] ()
28 :<|> "get" :> Get '[JSON] ()
30 :<|> "put" :> Put '[JSON] ()
29 :<|> "put" :> Put '[JSON] ()
31− :<|> "post" :> ReqBody 'True :> Post '[JSON] ()
30+ :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] ()
32 :<|> "delete" :> Header "ponies" :> Delete
31 :<|> "delete" :> Header "ponies" :> Delete
33 :<|> "raw" :> Raw
32 :<|> "raw" :> Raw
34
33
@@ -44,7 +43,7 @@ type BadTestLink' = "hello" :> "hi" :> Get '[HTML] Bool
44type BadTestLink'2 = "greet" :> Get '[HTML] Bool
43type BadTestLink'2 = "greet" :> Get '[HTML] Bool
45
44
46type NotALink = "hello" :> Capture "x" Bool :> Get '[JSON] Bool
45type NotALink = "hello" :> Capture "x" Bool :> Get '[JSON] Bool
47−type NotALink2 = "hello" :> ReqBody 'True :> Get '[JSON] Bool
46+type NotALink2 = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool
48
47
49apiLink :: (IsElem endpoint TestApi, HasLink endpoint)
48apiLink :: (IsElem endpoint TestApi, HasLink endpoint)
50 => Proxy endpoint -> MkLink endpoint
49 => Proxy endpoint -> MkLink endpoint