From 4690a0082a8046fc3ede9a85bc12c702c74c5ac7 Mon Sep 17 00:00:00 2001 From: Michael Wan Date: Mon, 2 Apr 2018 08:02:28 -0400 Subject: [PATCH] bugfix: restful api url should support both with version info and without version info Signed-off-by: Michael Wan --- apis/server/router.go | 2 ++ test/api_version_parameter_test.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apis/server/router.go b/apis/server/router.go index 8b4e990b8..f80e8a861 100644 --- a/apis/server/router.go +++ b/apis/server/router.go @@ -74,6 +74,7 @@ func initRoute(s *Server) http.Handler { // metrics r.Path(versionMatcher + "/metrics").Methods(http.MethodGet).Handler(prometheus.Handler()) + r.Path("/metrics").Methods(http.MethodGet).Handler(prometheus.Handler()) if s.Config.Debug { profilerSetup(r) @@ -83,6 +84,7 @@ func initRoute(s *Server) http.Handler { func addRoute(r *mux.Router, mothod string, path string, f func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error) { r.Path(versionMatcher + path).Methods(mothod).Handler(filter(f)) + r.Path(path).Methods(mothod).Handler(filter(f)) } func profilerSetup(mainRouter *mux.Router) { diff --git a/test/api_version_parameter_test.go b/test/api_version_parameter_test.go index 49a97550e..66decb375 100644 --- a/test/api_version_parameter_test.go +++ b/test/api_version_parameter_test.go @@ -25,6 +25,7 @@ func (suite *APIVersionSuite) SetUpTest(c *check.C) { } // TestNoVersionParamsInURL test api url not contains version info. +// Pouch api url support with or without version info. func (suite *APIVersionSuite) TestNoVersionParamsInURL(c *check.C) { cname := "TestCreateURLNoVersionInfo" @@ -55,5 +56,5 @@ func (suite *APIVersionSuite) TestNoVersionParamsInURL(c *check.C) { resp, err := apiClient.HTTPCli.Do(req) c.Assert(err, check.IsNil) - CheckRespStatus(c, resp, 404) + CheckRespStatus(c, resp, 201) }