Error handling for Go HTTP servers — structured error responses, error wrapping,
88
81%
Does it follow best practices?
Impact
99%
1.80xAverage score across 5 eval scenarios
Passed
No known issues
A cooking community wants a backend API for sharing recipes. Build it in Go using the standard library.
Resources:
{ id, title, author, ingredients (list of strings), instructions, servings, prepTimeMinutes, createdAt }{ id, recipeId, score (1-5), comment, createdAt }Endpoints:
GET /api/recipes -- list all recipesGET /api/recipes/{id} -- get a recipe with its average ratingPOST /api/recipes -- create a recipe (title, author, ingredients, instructions all required; servings > 0)PUT /api/recipes/{id} -- update a recipe (only the original author can update -- pass X-User header)DELETE /api/recipes/{id} -- delete a recipe (only the original author)POST /api/recipes/{id}/ratings -- add a rating to a recipe (score 1-5 required)GET /api/recipes/{id}/ratings -- list ratings for a recipeUse in-memory storage.
Produce:
main.go -- entry pointgo.modYou may split across files as you see fit.