diff --git a/gateway/internal/eventhandler.go b/gateway/internal/eventhandler.go index a840930f..e3a0f0c2 100644 --- a/gateway/internal/eventhandler.go +++ b/gateway/internal/eventhandler.go @@ -27,15 +27,6 @@ func NewEventHandler(writer io.Writer, resolver jsonpb.AnyResolver) *EventHandle } } -func (h *EventHandler) OnResolveMethod(_ *desc.MethodDescriptor) { -} - -func (h *EventHandler) OnSendHeaders(_ metadata.MD) { -} - -func (h *EventHandler) OnReceiveHeaders(_ metadata.MD) { -} - func (h *EventHandler) OnReceiveResponse(message proto.Message) { if err := h.marshaler.Marshal(h.writer, message); err != nil { logx.Error(err) @@ -45,3 +36,12 @@ func (h *EventHandler) OnReceiveResponse(message proto.Message) { func (h *EventHandler) OnReceiveTrailers(status *status.Status, _ metadata.MD) { h.Status = status } + +func (h *EventHandler) OnResolveMethod(_ *desc.MethodDescriptor) { +} + +func (h *EventHandler) OnSendHeaders(_ metadata.MD) { +} + +func (h *EventHandler) OnReceiveHeaders(_ metadata.MD) { +} diff --git a/gateway/internal/eventhandler_test.go b/gateway/internal/eventhandler_test.go new file mode 100644 index 00000000..cf81ace1 --- /dev/null +++ b/gateway/internal/eventhandler_test.go @@ -0,0 +1,20 @@ +package internal + +import ( + "io" + "testing" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func TestEventHandler(t *testing.T) { + h := NewEventHandler(io.Discard, nil) + h.OnResolveMethod(nil) + h.OnSendHeaders(nil) + h.OnReceiveHeaders(nil) + h.OnReceiveTrailers(status.New(codes.OK, ""), nil) + assert.Equal(t, codes.OK, h.Status.Code()) + h.OnReceiveResponse(nil) +}