diff --git a/api/http.go b/api/http.go index f35deb6565..6971353d3a 100644 --- a/api/http.go +++ b/api/http.go @@ -64,7 +64,7 @@ func newHTTPHandler(web3Handler Web3Handler) *hTTPHandler { func (handler *hTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { if req.Method != "POST" { - w.WriteHeader(http.StatusMethodNotAllowed) + w.Write([]byte("IoTeX RPC endpoint is ready.")) return } diff --git a/api/http_test.go b/api/http_test.go index f001fceca7..fa5be3e332 100644 --- a/api/http_test.go +++ b/api/http_test.go @@ -2,6 +2,7 @@ package api import ( "context" + "io" "net/http" "net/http/httptest" "strings" @@ -28,7 +29,9 @@ func TestServeHTTP(t *testing.T) { req.Header.Set("Content-Type", "application/json") resp := httptest.NewRecorder() svr.ServeHTTP(resp, req) - require.Equal(http.StatusMethodNotAllowed, resp.Result().StatusCode) + require.Equal(http.StatusOK, resp.Result().StatusCode) + bytes, _ := io.ReadAll(resp.Result().Body) + require.Equal("IoTeX RPC endpoint is ready.", string(bytes)) }) t.Run("Success", func(t *testing.T) {