diff --git a/relay/handlers/event.go b/relay/handlers/event.go index 63c91cd..13be0d9 100644 --- a/relay/handlers/event.go +++ b/relay/handlers/event.go @@ -45,7 +45,7 @@ func HandleEvent(ws *websocket.Conn, message []interface{}) { func HandleKind(ctx context.Context, evt relay.Event, ws *websocket.Conn) { if !utils.CheckSignature(evt) { - OKResponse(ws, evt.ID, false, "invalid: signature verification failed") + sendOK(ws, evt.ID, false, "invalid: signature verification failed") return } @@ -77,15 +77,11 @@ func HandleKind(ctx context.Context, evt relay.Event, ws *websocket.Conn) { } if err != nil { - OKResponse(ws, evt.ID, false, fmt.Sprintf("error: %v", err)) + sendOK(ws, evt.ID, false, fmt.Sprintf("error: %v", err)) return } - OKResponse(ws, evt.ID, true, "") + sendOK(ws, evt.ID, true, "") } -func OKResponse(ws *websocket.Conn, eventID string, status bool, message string) { - response := []interface{}{"OK", eventID, status, message} - responseBytes, _ := json.Marshal(response) - websocket.Message.Send(ws, string(responseBytes)) -} + diff --git a/relay/handlers/ok.go b/relay/handlers/ok.go new file mode 100644 index 0000000..c4151a6 --- /dev/null +++ b/relay/handlers/ok.go @@ -0,0 +1,13 @@ +package handlers + +import ( + "encoding/json" + + "golang.org/x/net/websocket" +) + +func sendOK(ws *websocket.Conn, eventID string, status bool, message string) { + response := []interface{}{"OK", eventID, status, message} + responseBytes, _ := json.Marshal(response) + websocket.Message.Send(ws, string(responseBytes)) +} \ No newline at end of file