toddmohney / json-api

Haskell Implementation of the JSON-API specification
http://hackage.haskell.org/package/json-api
MIT License
35 stars 14 forks source link

Endpoints on example's Readme are no longer in sync with code #33

Open penntaylor opened 6 years ago

penntaylor commented 6 years ago

README for the example server lists the following endpoints, but only the first currently works:

http://localhost:8080/users - responds with a list of User resources
http://localhost:8080/users/1 - responds with a singleton resource
http://localhost:8080/users/2 - responds with a singleton resource
http://localhost:8080/users/3 - responds with a 404 and error payload

It looks like the correct endpoints are:

http://localhost:8080/users - responds with a list of User resources
http://localhost:8080/users/1/simple - responds with a singleton resource
http://localhost:8080/users/1/full - responds with a singleton resource
http://localhost:8080/users/2/simple - responds with a singleton resource
http://localhost:8080/users/2/full - responds with a singleton resource
http://localhost:8080/users/3/simple - responds with a 404 and error payload
http://localhost:8080/users/3/full - responds with a 404 and error payload

Alternatively, to make the originally stated endpoints available, the following endpoint can be added to the API type in example/src/Lib.hs:

:<|> "users" :> Capture "id" Int :> Get '[JSON] (Document User)

Along with a matching handler on the Server in the same file:

:<|> Controller.userShowSimple   -- or userShowFull