diff options
| author | xengineering <me@xengineering.eu> | 2026-08-13 20:53:24 +0200 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-08-13 21:15:49 +0200 |
| commit | 60bdc926dd7235fd55930ebd5b30c2e346f8ca59 (patch) | |
| tree | a520a7d898af7bb0cda0a3d2644bd3cb7fc17070 /model/recipe.go | |
| parent | 5f66b2fc93d84cedd605bbacbd602cec98efc358 (diff) | |
| download | ceres-60bdc926dd7235fd55930ebd5b30c2e346f8ca59.tar ceres-60bdc926dd7235fd55930ebd5b30c2e346f8ca59.tar.zst ceres-60bdc926dd7235fd55930ebd5b30c2e346f8ca59.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 'model/recipe.go')
| -rw-r--r-- | model/recipe.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/model/recipe.go b/model/recipe.go index 684b158..adcafa1 100644 --- a/model/recipe.go +++ b/model/recipe.go @@ -5,6 +5,8 @@ import ( "encoding/json" "errors" "fmt" + "log" + "strconv" ) type Recipe struct { @@ -19,11 +21,23 @@ type Recipe struct { IsFavorite bool `json:"is_favorite"` } +func NewRecipe() Object { + return &Recipe{} +} + func (r Recipe) String() string { b, _ := json.MarshalIndent(r, "", " ") return string(b) } +func (r *Recipe) SetID(id int) { + if r == nil { + log.Println("Got nil as recipe!") + } + + r.Id = strconv.Itoa(id) +} + func (r *Recipe) Validate() error { var err error |
