git.iko.soy/typeable/servant
on master help sign in
Updated docs
8550926Catherine Galkina
doc/tutorial/ApiType.lhs+3−4
@@ -177,13 +177,12 @@ type UserAPI5 = "user" :> Capture "userid" Integer :> Get '[JSON] User
177 -- except that we explicitly say that "userid"
177 -- except that we explicitly say that "userid"
178 -- must be an integer
178 -- must be an integer
179
179
180− :<|> "user" :> Capture "userid" Integer :> DeleteNoContent '[JSON] NoContent
180+ :<|> "user" :> Capture "userid" Integer :> DeleteNoContent
181 -- equivalent to 'DELETE /user/:userid'
181 -- equivalent to 'DELETE /user/:userid'
182```
182```
183
183
184−In the second case, `DeleteNoContent` specifies a 204 response code,
184+In the second case, `DeleteNoContent` specifies a 204 response code
185−`JSON` specifies the content types on which the handler will match,
186−and `NoContent` says that the response will always be empty.
185+and that the response will always be empty.
187
186
188### `QueryParam`, `QueryParams`, `QueryFlag`
187### `QueryParam`, `QueryParams`, `QueryFlag`
189
188
doc/tutorial/Server.lhs+13−13
@@ -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
831
831
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
834```
834```
835
835
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
842 )
842 )
843```
843```
844
844
@@ -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
900 )
900 )
901
901
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
906 )
906 )
907
907
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
923 )
923 )
924
924
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
956 )
956 )
957
957
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'
1004 )
1004 )
1005
1005
1006-- Build the appropriate 'Server'
1006-- Build the appropriate 'Server'