summaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-08-13 20:53:24 +0200
committerxengineering <me@xengineering.eu>2026-08-13 21:15:49 +0200
commit60bdc926dd7235fd55930ebd5b30c2e346f8ca59 (patch)
treea520a7d898af7bb0cda0a3d2644bd3cb7fc17070 /server.go
parent5f66b2fc93d84cedd605bbacbd602cec98efc358 (diff)
downloadceres-step-re-ordering.tar
ceres-step-re-ordering.tar.zst
ceres-step-re-ordering.zip
WIP: Add JSON-based API under `/api`step-re-ordering
TODO: Not all the information is provided there. This commit provides an unstable JSON API for communication with an upcoming Dart frontend. Later it might be part of the public interface for integration into other services. For this step it has to be ensured the semantics are not changing a lot in the future which is currently out of scope.
Diffstat (limited to 'server.go')
-rw-r--r--server.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/server.go b/server.go
index 3868315..07389a8 100644
--- a/server.go
+++ b/server.go
@@ -30,9 +30,15 @@ func NewServer(addr string, db *model.DB) *Server {
mux.Handle("GET /recipes", view.RecipesRead(db))
mux.Handle("GET /recipe/create", view.RecipeCreate())
+
+ mux.Handle("POST /api/recipe", view.CreateJSON[*model.Recipe](db, model.NewRecipe))
mux.Handle("POST /recipe", controller.RecipeCreate(db))
+
+ mux.Handle("GET /api/recipe/{id}", view.ReadJSON[*model.Recipe](db, model.NewRecipe))
mux.Handle("GET /recipe/{id}", view.RecipeRead(db))
+
mux.Handle("POST /recipe/{id}", controller.RecipeUpdate(db))
+
mux.Handle("DELETE /recipe/{id}", controller.RecipeDelete(db))
mux.Handle("GET /favicon.ico", view.FaviconRead())