From c43e85dbbd0401146c53f35e6aff328201742ca4 Mon Sep 17 00:00:00 2001 From: Dmitry Kolesnikov Date: Sun, 17 Mar 2024 17:09:20 +0200 Subject: [PATCH] Fix Event for WebSocket Gateway --- broker/websocket/websocket.go | 5 +++-- event.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/broker/websocket/websocket.go b/broker/websocket/websocket.go index e981fe7..8703501 100644 --- a/broker/websocket/websocket.go +++ b/broker/websocket/websocket.go @@ -11,6 +11,7 @@ package websocket import ( "context" "log/slog" + "net/http" "strings" "github.com/aws/aws-lambda-go/events" @@ -150,10 +151,10 @@ func (s spawner) Spawn(k *kernel.Kernel) error { bag := []swarm.Bag{{Ctx: ctx, Object: []byte(evt.Body)}} if err := k.Dispatch(bag, s.c.TimeToFlight); err != nil { - return events.APIGatewayProxyResponse{StatusCode: 500}, err + return events.APIGatewayProxyResponse{StatusCode: http.StatusRequestTimeout}, err } - return events.APIGatewayProxyResponse{StatusCode: 200}, nil + return events.APIGatewayProxyResponse{StatusCode: http.StatusOK}, nil }, ) diff --git a/event.go b/event.go index 628646e..03617c9 100644 --- a/event.go +++ b/event.go @@ -34,12 +34,12 @@ type Event[T any] struct { // // Unique identity for event // It is automatically defined by the library upon the transmission - ID string `json:"@id,omitempty"` + ID string `json:"id,omitempty"` // // Canonical IRI that defines a type of action. // It is automatically defined by the library upon the transmission - Type curie.IRI `json:"@type,omitempty"` + Type curie.IRI `json:"type,omitempty"` // // Direct performer of the event, a software service that emits action to the stream.