Build a JSON API endpoint
This recipe creates a small JSON endpoint with validation and throttling.
Route
Register an API route for the controller action that creates the resource.
Controller
Validate the request and return the stored model in a JSON response.
Validation failures for JSON requests return JSON 422 responses.
Test
Exercise the endpoint as JSON and assert the response status and payload.