add GET/v1/state/XYZ

main
Bel LaPointe 2024-12-15 02:50:42 -07:00
parent 808266d9c9
commit 52aad4008c
1 changed files with 10 additions and 1 deletions

View File

@ -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
}