liveBook · Manning

PostCreated

As explained in Learn Haskell by Example

PostCreated is a Servant response type representing a successful HTTP resource-creation response with status code 201.

PostCreated is a Servant response type for a successful resource-creation request. It declares HTTP status 201 and can describe a JSON response, such as the new resource's integer ID. section 17.1.1

Todo-list creation endpoint

A POST request to /add accepts a JSON-encoded TodoEntry and returns the created entry's ID with status 201. section 17.1.1

"add" :> ReqBody '[JSON] TodoEntry :> PostCreated '[JSON] Int

This endpoint combines a path, a JSON request body, and a PostCreated JSON response carrying an Int. section 17.1.1

How Learn Haskell by Example covers it

How deep it goes
Defines the response status and payload shape, but does not describe handler implementation or HTTP-server operations.
Examples
Uses a todo-list /add endpoint that accepts TodoEntry and returns an integer identifier.
What it assumes
Assumes familiarity with Servant API combinators, POST requests, JSON request bodies, and Haskell endpoint types.
What you can do after
Apply it via Servant to type an endpoint that returns JSON after successfully creating a resource.
How it connects
Connects POST requests, JSON encoding, request bodies, resource creation, and HTTP status code 201.

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.