Skip to content

Commit 4690a00

Browse files
committed
bugfix: restful api url should support both with version info and without version info
Signed-off-by: Michael Wan <[email protected]>
1 parent 85d808d commit 4690a00

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

apis/server/router.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func initRoute(s *Server) http.Handler {
7474

7575
// metrics
7676
r.Path(versionMatcher + "/metrics").Methods(http.MethodGet).Handler(prometheus.Handler())
77+
r.Path("/metrics").Methods(http.MethodGet).Handler(prometheus.Handler())
7778

7879
if s.Config.Debug {
7980
profilerSetup(r)
@@ -83,6 +84,7 @@ func initRoute(s *Server) http.Handler {
8384

8485
func addRoute(r *mux.Router, mothod string, path string, f func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error) {
8586
r.Path(versionMatcher + path).Methods(mothod).Handler(filter(f))
87+
r.Path(path).Methods(mothod).Handler(filter(f))
8688
}
8789

8890
func profilerSetup(mainRouter *mux.Router) {

test/api_version_parameter_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (suite *APIVersionSuite) SetUpTest(c *check.C) {
2525
}
2626

2727
// TestNoVersionParamsInURL test api url not contains version info.
28+
// Pouch api url support with or without version info.
2829
func (suite *APIVersionSuite) TestNoVersionParamsInURL(c *check.C) {
2930
cname := "TestCreateURLNoVersionInfo"
3031

@@ -55,5 +56,5 @@ func (suite *APIVersionSuite) TestNoVersionParamsInURL(c *check.C) {
5556
resp, err := apiClient.HTTPCli.Do(req)
5657
c.Assert(err, check.IsNil)
5758

58-
CheckRespStatus(c, resp, 404)
59+
CheckRespStatus(c, resp, 201)
5960
}

0 commit comments

Comments
 (0)