diff --git a/services/json-rpc/cache/json_rpc_cache.go b/services/json-rpc/cache/json_rpc_cache.go index 70c76d1d..4f98f29c 100644 --- a/services/json-rpc/cache/json_rpc_cache.go +++ b/services/json-rpc/cache/json_rpc_cache.go @@ -95,17 +95,16 @@ func (p *JsonRpcCache) Name() string { func (c *JsonRpcCache) Handler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - var err error - t := time.Now() - req, err := decodeBody(r) + agentConfig, err := c.botAuthenticator.FindAgentFromRemoteAddr(r.RemoteAddr) if err != nil { - writeBadRequest(w, req, err) + writeUnauthorized(w, nil) return } - agentConfig, err := c.botAuthenticator.FindAgentFromRemoteAddr(r.RemoteAddr) - if agentConfig == nil || err != nil { - writeUnauthorized(w, req) + t := time.Now() + req, err := decodeBody(r) + if err != nil { + writeBadRequest(w, req, err) return } @@ -165,6 +164,12 @@ func (c *JsonRpcCache) Handler() http.Handler { func (c *JsonRpcCache) HealthHandler() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, err := c.botAuthenticator.FindAgentFromRemoteAddr(r.RemoteAddr) + if err != nil { + writeUnauthorized(w, nil) + return + } + chainID, err := strconv.ParseInt(mux.Vars(r)["chainID"], 10, 64) if err != nil { w.WriteHeader(http.StatusBadRequest)