diff --git a/src/xrpc/README.md b/src/xrpc/README.md index e363a1c..21f87ba 100644 --- a/src/xrpc/README.md +++ b/src/xrpc/README.md @@ -108,13 +108,13 @@ The necessary functions are encapsulated internally for unified management ```go s := &xrpc.RpcServer{ - Grpc: &xrpc.Grpc{ + GrpcServer: &xrpc.GrpcServer{ Addr: "0.0.0.0:50000", Registrar: func(s *grpc.Server) { pb.RegisterOrderServer(s, &service{}) }, }, - Gateway: &xrpc.Gateway{ // Optional + GatewayServer: &xrpc.GatewayServer{ // Optional Addr: "0.0.0.0:50001", Registrar: func(mux *runtime.ServeMux, conn *grpc.ClientConn) { pb.RegisterOrderHandler(context.Background(), mux, conn) @@ -145,13 +145,13 @@ if err != nil { log.Fatal(err) } s := &xrpc.RpcServer{ - Grpc: &xrpc.Grpc{ + GrpcServer: &xrpc.GrpcServer{ Addr: "0.0.0.0:50000", Registrar: func(s *grpc.Server) { pb.RegisterOrderServer(s, &service{}) }, }, - Gateway: &xrpc.Gateway{ // Optional + GatewayServer: &xrpc.GatewayServer{ // Optional Addr: "0.0.0.0:50001", Registrar: func(mux *runtime.ServeMux, conn *grpc.ClientConn) { pb.RegisterOrderHandler(context.Background(), mux, conn) @@ -181,7 +181,7 @@ Loggable Events ```go s := &xrpc.RpcServer{ - Grpc: &xrpc.Grpc{ + GrpcServer: &xrpc.GrpcServer{ LoggableEvents: []logging.LoggableEvent{logging.StartCall, logging.FinishCall}, } } diff --git a/src/xrpc/rpcserver.go b/src/xrpc/rpcserver.go index 0bfad46..77e8745 100644 --- a/src/xrpc/rpcserver.go +++ b/src/xrpc/rpcserver.go @@ -164,9 +164,8 @@ func (t *RpcServer) Serve() error { t.GatewayServer.Registrar(mux, conn) requestLogger := func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + t.Logger.Log(r.Context(), logging.LevelInfo, "gateway request", "method", r.Method, "path", r.URL.Path, "remote_addr", r.RemoteAddr) next.ServeHTTP(w, r) - statusCode := w.(interface{ StatusCode() int }).StatusCode() - t.Logger.Log(r.Context(), logging.LevelInfo, "gateway request", "method", r.Method, "path", r.URL.Path, "remote_addr", r.RemoteAddr, "status_code", statusCode) }) } gateway := &http.Server{