From cddb78ed6cbe552dff7a8f7e5ef6d84af133d228 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Fri, 26 Jul 2024 13:22:27 -0400 Subject: [PATCH] remove HTTPRegistrar interface in preference of Registrar --- rpcs/blockService.go | 8 +------- rpcs/registrar.go | 2 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/rpcs/blockService.go b/rpcs/blockService.go index b0db652e12..410376a20f 100644 --- a/rpcs/blockService.go +++ b/rpcs/blockService.go @@ -152,14 +152,8 @@ func MakeBlockService(log logging.Logger, config config.Local, ledger LedgerForB return service } -// HTTPRegistrar represents an HTTP request router that can be used by BlockService -// to register its request handlers. -type HTTPRegistrar interface { - RegisterHTTPHandlerFunc(path string, handler func(response http.ResponseWriter, request *http.Request)) -} - // RegisterHandlers registers the request handlers for BlockService's paths with the registrar. -func (bs *BlockService) RegisterHandlers(registrar HTTPRegistrar) { +func (bs *BlockService) RegisterHandlers(registrar Registrar) { registrar.RegisterHTTPHandlerFunc(BlockServiceBlockPath, bs.ServeBlockPath) } diff --git a/rpcs/registrar.go b/rpcs/registrar.go index f488aebf26..f0122b552c 100644 --- a/rpcs/registrar.go +++ b/rpcs/registrar.go @@ -26,6 +26,8 @@ import ( type Registrar interface { // RegisterHTTPHandler path accepts gorilla/mux path annotations RegisterHTTPHandler(path string, handler http.Handler) + // RegisterHTTPHandlerFunc path accepts gorilla/mux path annotations and a HandlerFunc + RegisterHTTPHandlerFunc(path string, handler func(response http.ResponseWriter, request *http.Request)) // RegisterHandlers exposes global websocket handler registration RegisterHandlers(dispatch []network.TaggedMessageHandler) }