fix: idx to index
This commit is contained in:
parent
5e87ccda79
commit
50b44a7bb7
5
Makefile
5
Makefile
|
@ -21,3 +21,8 @@ endif
|
|||
|
||||
load:
|
||||
watch -n .1 "http POST localhost:8080/event/asdf/test a=b one=1 two:='{\"v\":2}' | jq"
|
||||
|
||||
bi:
|
||||
go build .
|
||||
sudo mv ev /usr/local/bin/
|
||||
sudo systemctl restart ev
|
||||
|
|
1
go.mod
1
go.mod
|
@ -14,6 +14,7 @@ require (
|
|||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.4 // indirect
|
||||
github.com/mitchellh/mapstructure v1.3.1 // indirect
|
||||
github.com/rs/cors v1.8.2 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
2
go.sum
2
go.sum
|
@ -37,6 +37,8 @@ github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNs
|
|||
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
|
||||
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
|
|
24
main.go
24
main.go
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -9,8 +10,9 @@ import (
|
|||
"time"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
"github.com/rs/cors"
|
||||
|
||||
"github.com/sour-is/ev/api/gql_ev"
|
||||
"github.com/sour-is/ev/internal/graph"
|
||||
"github.com/sour-is/ev/internal/graph/generated"
|
||||
|
@ -53,9 +55,23 @@ func run(ctx context.Context) error {
|
|||
s := http.Server{
|
||||
Addr: env("EV_HTTP", ":8080"),
|
||||
}
|
||||
http.Handle("/", playground.Handler("GraphQL playground", "/gql"))
|
||||
http.Handle("/gql", res.ChainMiddlewares(gql))
|
||||
http.Handle("/event/", http.StripPrefix("/event/", svc))
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle("/", playground.Handler("GraphQL playground", "/gql"))
|
||||
mux.Handle("/gql", res.ChainMiddlewares(gql))
|
||||
mux.Handle("/inbox/", http.StripPrefix("/inbox/", svc))
|
||||
|
||||
wk := http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintln(w, `{
|
||||
"endpoint": "https://ev.sour.is/inbox/01GA4Q3NDX4TPAZ2EZ8E92CQE6",
|
||||
"key": "kex1pqwqatj6sge7qaqrsvk4u4yhue4x3vej8znetkwj6a5k0xds2fmqqe3plh"
|
||||
}`)
|
||||
},
|
||||
)
|
||||
mux.Handle("/.well-known/salty/0ce550020ce36a9932b286b141edd515d33c2b0f51c715445de89ae106345993.json", wk)
|
||||
|
||||
s.Handler = cors.AllowAll().Handler(mux)
|
||||
|
||||
log.Print("Listen on ", s.Addr)
|
||||
g, ctx := errgroup.WithContext(ctx)
|
||||
|
|
|
@ -67,7 +67,7 @@ func (s *service) get(w http.ResponseWriter, r *http.Request) {
|
|||
var pos, count int64 = -1, -99
|
||||
qry := r.URL.Query()
|
||||
|
||||
if i, err := strconv.ParseInt(qry.Get("idx"), 10, 64); err == nil {
|
||||
if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil {
|
||||
pos = i
|
||||
}
|
||||
if i, err := strconv.ParseInt(qry.Get("n"), 10, 64); err == nil {
|
||||
|
@ -177,7 +177,7 @@ func (s *service) websocket(w http.ResponseWriter, r *http.Request) {
|
|||
var pos int64 = -1
|
||||
qry := r.URL.Query()
|
||||
|
||||
if i, err := strconv.ParseInt(qry.Get("idx"), 10, 64); err == nil {
|
||||
if i, err := strconv.ParseInt(qry.Get("index"), 10, 64); err == nil {
|
||||
pos = i
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user