Skip to content

Commit

Permalink
Merge pull request #239 from OffchainLabs/http-handler-wrapper
Browse files Browse the repository at this point in the history
Http handler wrapper
  • Loading branch information
Tristan-Wilson authored Jul 7, 2023
2 parents 8e6a8ad + 28127f5 commit 6afe422
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 6afe422

Please sign in to comment.