@@ -830,7 +830,7 @@ type UserAPI3 = -- view the user with given userid, in JSON
830 Capture "userid" Int :> Get '[JSON] User
830 Capture "userid" Int :> Get '[JSON] User
832 :<|> -- delete the user with given userid. empty response
832 :<|> -- delete the user with given userid. empty response
833− Capture "userid" Int :> DeleteNoContent '[JSON] NoContent
833+ Capture "userid" Int :> DeleteNoContent
836We can instead factor out the `userid`:
836We can instead factor out the `userid`:
@@ -838,7 +838,7 @@ We can instead factor out the `userid`:
838``` haskell
838``` haskell
839type UserAPI4 = Capture "userid" Int :>
839type UserAPI4 = Capture "userid" Int :>
840 ( Get '[JSON] User
840 ( Get '[JSON] User
841− :<|> DeleteNoContent '[JSON] NoContent
841+ :<|> DeleteNoContent
@@ -896,13 +896,13 @@ type API1 = "users" :>
896-- we factor out the Request Body
896-- we factor out the Request Body
897type API2 = ReqBody '[JSON] User :>
897type API2 = ReqBody '[JSON] User :>
898 ( Get '[JSON] User -- just display the same user back, don't register it
898 ( Get '[JSON] User -- just display the same user back, don't register it
899− :<|> PostNoContent '[JSON] NoContent -- register the user. empty response
899+ :<|> PostNoContent -- register the user. empty response
902-- we factor out a Header
902-- we factor out a Header
903type API3 = Header "Authorization" Token :>
903type API3 = Header "Authorization" Token :>
904 ( Get '[JSON] SecretData -- get some secret data, if authorized
904 ( Get '[JSON] SecretData -- get some secret data, if authorized
905− :<|> ReqBody '[JSON] SecretData :> PostNoContent '[JSON] NoContent -- add some secret data, if authorized
905+ :<|> ReqBody '[JSON] SecretData :> PostNoContent -- add some secret data, if authorized
908newtype Token = Token ByteString
908newtype Token = Token ByteString
@@ -915,11 +915,11 @@ API type only at the end.
915``` haskell
915``` haskell
916type UsersAPI =
916type UsersAPI =
917 Get '[JSON] [User] -- list users
917 Get '[JSON] [User] -- list users
918− :<|> ReqBody '[JSON] User :> PostNoContent '[JSON] NoContent -- add a user
918+ :<|> ReqBody '[JSON] User :> PostNoContent -- add a user
919 :<|> Capture "userid" Int :>
919 :<|> Capture "userid" Int :>
920 ( Get '[JSON] User -- view a user
920 ( Get '[JSON] User -- view a user
921− :<|> ReqBody '[JSON] User :> PutNoContent '[JSON] NoContent -- update a user
921+ :<|> ReqBody '[JSON] User :> PutNoContent -- update a user
922− :<|> DeleteNoContent '[JSON] NoContent -- delete a user
922+ :<|> DeleteNoContent -- delete a user
925usersServer :: Server UsersAPI
925usersServer :: Server UsersAPI
@@ -948,11 +948,11 @@ usersServer = getUsers :<|> newUser :<|> userOperations
948``` haskell
948``` haskell
949type ProductsAPI =
949type ProductsAPI =
950 Get '[JSON] [Product] -- list products
950 Get '[JSON] [Product] -- list products
951− :<|> ReqBody '[JSON] Product :> PostNoContent '[JSON] NoContent -- add a product
951+ :<|> ReqBody '[JSON] Product :> PostNoContent -- add a product
952 :<|> Capture "productid" Int :>
952 :<|> Capture "productid" Int :>
953 ( Get '[JSON] Product -- view a product
953 ( Get '[JSON] Product -- view a product
954− :<|> ReqBody '[JSON] Product :> PutNoContent '[JSON] NoContent -- update a product
954+ :<|> ReqBody '[JSON] Product :> PutNoContent -- update a product
955− :<|> DeleteNoContent '[JSON] NoContent -- delete a product
955+ :<|> DeleteNoContent -- delete a product
958data Product = Product { productId :: Int }
958data Product = Product { productId :: Int }
@@ -996,11 +996,11 @@ abstract that away:
996-- indexed by values of type 'i'
996-- indexed by values of type 'i'
997type APIFor a i =
997type APIFor a i =
998 Get '[JSON] [a] -- list 'a's
998 Get '[JSON] [a] -- list 'a's
999− :<|> ReqBody '[JSON] a :> PostNoContent '[JSON] NoContent -- add an 'a'
999+ :<|> ReqBody '[JSON] a :> PostNoContent -- add an 'a'
1000 :<|> Capture "id" i :>
1000 :<|> Capture "id" i :>
1001 ( Get '[JSON] a -- view an 'a' given its "identifier" of type 'i'
1001 ( Get '[JSON] a -- view an 'a' given its "identifier" of type 'i'
1002− :<|> ReqBody '[JSON] a :> PutNoContent '[JSON] NoContent -- update an 'a'
1002+ :<|> ReqBody '[JSON] a :> PutNoContent -- update an 'a'
1003− :<|> DeleteNoContent '[JSON] NoContent -- delete an 'a'
1003+ :<|> DeleteNoContent -- delete an 'a'
1006-- Build the appropriate 'Server'
1006-- Build the appropriate 'Server'