From 807ea7338aa80730c54e7b6c62fdc1a8c3369b4f Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 29 Jun 2023 10:25:02 -0700 Subject: [PATCH] Add a hook so the rpc http handler can be wrapped --- node/rpcstack.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/node/rpcstack.go b/node/rpcstack.go index 97d591642c..16d51b3371 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -286,6 +286,11 @@ func (h *httpServer) doStop() { h.server, h.listener = nil, nil } +// Arbitrum: Allows injection of custom http.Handler functionality. +var WrapHTTPHandler = func(srv http.Handler) (http.Handler, error) { + return srv, nil +} + // enableRPC turns on JSON-RPC over HTTP on the server. func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error { h.mu.Lock() @@ -300,9 +305,15 @@ func (h *httpServer) enableRPC(apis []rpc.API, config httpConfig) error { if err := RegisterApis(apis, config.Modules, srv); err != nil { return err } + + httpHandler, err := WrapHTTPHandler(srv) + if err != nil { + return err + } + h.httpConfig = config h.httpHandler.Store(&rpcHandler{ - Handler: NewHTTPHandlerStack(srv, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret), + Handler: NewHTTPHandlerStack(httpHandler, config.CorsAllowedOrigins, config.Vhosts, config.jwtSecret), server: srv, }) return nil