Skip to content

Commit

Permalink
use request.Read for events
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Feb 8, 2024
1 parent 18fea2e commit 844b35b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions api/events.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package api

import (
"io"
"net"
"net/http"

v1 "github.com/vinceanalytics/vince/gen/go/staples/v1"
"github.com/vinceanalytics/vince/guard"
"github.com/vinceanalytics/vince/request"
"github.com/vinceanalytics/vince/session"
"google.golang.org/protobuf/encoding/protojson"
)

func ReceiveEvent(w http.ResponseWriter, r *http.Request) {
Expand All @@ -20,10 +19,7 @@ func ReceiveEvent(w http.ResponseWriter, r *http.Request) {
return
}
var ev v1.Event
b, _ := io.ReadAll(io.LimitReader(r.Body, 1<<20))
err := protojson.Unmarshal(b, &ev)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
if !request.Read(w, r, &ev) {
return
}
if !xg.Accept(ev.D) {
Expand Down

0 comments on commit 844b35b

Please sign in to comment.