From 52aad4008ce22de39eb07dc5a0dc08abea20feb3 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Sun, 15 Dec 2024 02:50:42 -0700 Subject: [PATCH] add GET/v1/state/XYZ --- cmd/testapi/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/testapi/main.go b/cmd/testapi/main.go index a832b26..1f905b8 100644 --- a/cmd/testapi/main.go +++ b/cmd/testapi/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "crypto/rand" "flag" "fmt" "io" @@ -174,9 +175,17 @@ func (s *S) serveWS(w http.ResponseWriter, r *http.Request) error { func (s *S) serveV1(w http.ResponseWriter, r *http.Request) error { ctx := r.Context() switch r.Method + r.URL.Path { + case "GET/v1/state/" + s.Session(ctx).ID: + if rand.Int()%2 == 0 { + w.Write(`{"name": "foo"}`) + } else { + w.Write(`{"name": "bar", "party": "party name"}`) + } case "PUT/v1/state/" + s.Session(ctx).ID + "/party": + w.Write(`{}`) + default: + http.NotFound(w, r) return nil } - http.NotFound(w, r) return nil }