From 59a20b2974044a9acf756ccdc8b42b5e1b935b20 Mon Sep 17 00:00:00 2001 From: Timo von Holtz Date: Tue, 10 Feb 2015 11:06:42 +1100 Subject: [PATCH 1/2] Add PATCH method --- servant.cabal | 1 + src/Servant/API.hs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/servant.cabal b/servant.cabal index 7c39011a..15762f39 100644 --- a/servant.cabal +++ b/servant.cabal @@ -31,6 +31,7 @@ library Servant.API.Delete Servant.API.Get Servant.API.Header + Servant.API.Patch Servant.API.Post Servant.API.Put Servant.API.QueryParam diff --git a/src/Servant/API.hs b/src/Servant/API.hs index e30e3642..9deee23a 100644 --- a/src/Servant/API.hs +++ b/src/Servant/API.hs @@ -27,6 +27,8 @@ module Servant.API ( module Servant.API.Delete, -- | PUT requests module Servant.API.Put, + -- | PATCH requests + module Servant.API.Patch, -- * Untyped endpoints -- | Plugging in a wai 'Network.Wai.Application', serving directories @@ -46,6 +48,7 @@ import Servant.API.Get ( Get ) import Servant.API.Header ( Header ) import Servant.API.Post ( Post ) import Servant.API.Put ( Put ) +import Servant.API.Patch ( Patch ) import Servant.API.QueryParam ( QueryFlag, QueryParams, QueryParam ) import Servant.API.MatrixParam ( MatrixFlag, MatrixParams, MatrixParam ) import Servant.API.Raw ( Raw ) From 71011745c0692f52994ad82df6f096cce23a4abe Mon Sep 17 00:00:00 2001 From: Timo von Holtz Date: Tue, 10 Feb 2015 11:28:16 +1100 Subject: [PATCH 2/2] Actually include the Patch.hs --- src/Servant/API/Patch.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/Servant/API/Patch.hs diff --git a/src/Servant/API/Patch.hs b/src/Servant/API/Patch.hs new file mode 100644 index 00000000..d2643d5b --- /dev/null +++ b/src/Servant/API/Patch.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveDataTypeable #-} +module Servant.API.Patch where + +import Data.Typeable ( Typeable ) + +-- | Endpoint for PATCH requests. The type variable represents the type of the +-- response body (not the request body, use 'Servant.API.ReqBody.ReqBody' for +-- that). +-- +-- If the HTTP response is empty, only () is supported. +-- +-- Example: +-- +-- > -- POST /books +-- > -- with a JSON encoded Book as the request body +-- > -- returning the just-created Book +-- > type MyApi = "books" :> ReqBody Book :> Post Book +data Patch a + deriving Typeable