Skip to content

Commit

Permalink
feat(master): add socket
Browse files Browse the repository at this point in the history
  • Loading branch information
thaisonenouvo committed Nov 23, 2023
1 parent 2769560 commit 9735e36
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/api/ws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
)

type Body struct {
action string
payload interface{}
Action string `json:"action"`
}

func Handler(ctx context.Context, event events.APIGatewayWebsocketProxyRequest) (events.APIGatewayProxyResponse, error) {
Expand All @@ -21,7 +20,8 @@ func Handler(ctx context.Context, event events.APIGatewayWebsocketProxyRequest)
return events.APIGatewayProxyResponse{}, err
}

body := Body{}
var body Body

err = json.Unmarshal([]byte(event.Body), &body)
if err != nil {
return events.APIGatewayProxyResponse{}, err
Expand All @@ -34,8 +34,8 @@ func Handler(ctx context.Context, event events.APIGatewayWebsocketProxyRequest)
return handlers.Disconnect(ctx, event)
case "$default":
fmt.Print(event.Body)
fmt.Println(body.action)
switch body.action {
fmt.Println(body.Action)
switch body.Action {
case "SEND_MESSAGE":
return handlers.SendMessageSocket(ctx, event)
default:
Expand Down

1 comment on commit 9735e36

@vercel
Copy link

@vercel vercel bot commented on 9735e36 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.