add GET/v1/state/XYZ
parent
808266d9c9
commit
52aad4008c
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"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 {
|
func (s *S) serveV1(w http.ResponseWriter, r *http.Request) error {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
switch r.Method + r.URL.Path {
|
switch r.Method + r.URL.Path {
|
||||||
case "PUT/v1/state/" + s.Session(ctx).ID + "/party":
|
case "GET/v1/state/" + s.Session(ctx).ID:
|
||||||
return nil
|
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)
|
http.NotFound(w, r)
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue