add GET/v1/state/XYZ
parent
808266d9c9
commit
52aad4008c
|
|
@ -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 "PUT/v1/state/" + s.Session(ctx).ID + "/party":
|
||||
return nil
|
||||
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
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue