Skip to content

Commit

Permalink
fix the encoded path
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <rleungx@gmail.com>
  • Loading branch information
rleungx committed May 7, 2020
1 parent 5a8ccb5 commit b6a1c28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func createRouter(ctx context.Context, prefix string, svr *server.Server) *mux.R

regionHandler := newRegionHandler(svr, rd)
clusterRouter.HandleFunc("/region/id/{id}", regionHandler.GetRegionByID).Methods("GET")
clusterRouter.HandleFunc("/region/key/{key}", regionHandler.GetRegionByKey).Methods("GET")
clusterRouter.UseEncodedPath().HandleFunc("/region/key/{key}", regionHandler.GetRegionByKey).Methods("GET")

srd := createStreamingRender()
regionsAllHandler := newRegionsHandler(svr, srd)
Expand Down
8 changes: 8 additions & 0 deletions tests/pdctl/region/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ func (s *regionTestSuite) TestRegion(c *C) {
c.Assert(json.Unmarshal(output, &regionInfo), IsNil)
c.Assert(&regionInfo, DeepEquals, api.NewRegionInfo(r2))

// issue #2351
args = []string{"-u", pdAddr, "region", "key", "--format=hex", "622f62"}
_, output, err = pdctl.ExecuteCommandC(cmd, args...)
c.Assert(err, IsNil)
regionInfo = api.RegionInfo{}
c.Assert(json.Unmarshal(output, &regionInfo), IsNil)
c.Assert(&regionInfo, DeepEquals, api.NewRegionInfo(r2))

// region startkey --format=raw <key> command
args = []string{"-u", pdAddr, "region", "startkey", "--format=raw", "b", "2"}
_, output, err = pdctl.ExecuteCommandC(cmd, args...)
Expand Down

0 comments on commit b6a1c28

Please sign in to comment.