Skip to content

Commit

Permalink
address comment
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <cabinfeveroier@gmail.com>
  • Loading branch information
CabinfeverB committed Jan 30, 2024
1 parent 43e35e4 commit d0ec9b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
1 change: 1 addition & 0 deletions pkg/utils/apiutil/apiutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ var once sync.Once

func init() {
once.Do(func() {
// See https://github.com/pingcap/tidb-dashboard/blob/f8ecb64e3d63f4ed91c3dca7a04362418ade01d8/pkg/apiserver/apiserver.go#L84
// These global modification will be effective only for the first invoke.
_ = godotenv.Load()
gin.SetMode(gin.ReleaseMode)
Expand Down
10 changes: 0 additions & 10 deletions server/apiv2/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ package apiv2
import (
"context"
"net/http"
"sync"

"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/tikv/pd/pkg/utils/apiutil"
"github.com/tikv/pd/server"
"github.com/tikv/pd/server/apiv2/handlers"
"github.com/tikv/pd/server/apiv2/middlewares"
)

var once sync.Once

var group = apiutil.APIServiceGroup{
Name: "core",
IsCore: true,
Expand All @@ -49,12 +45,6 @@ const apiV2Prefix = "/pd/api/v2/"
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @BasePath /pd/api/v2
func NewV2Handler(_ context.Context, svr *server.Server) (http.Handler, apiutil.APIServiceGroup, error) {
once.Do(func() {
// See https://github.com/pingcap/tidb-dashboard/blob/f8ecb64e3d63f4ed91c3dca7a04362418ade01d8/pkg/apiserver/apiserver.go#L84
// These global modification will be effective only for the first invoke.
_ = godotenv.Load()
gin.SetMode(gin.ReleaseMode)
})
router := gin.New()
router.Use(func(c *gin.Context) {
c.Set(middlewares.ServerContextKey, svr)
Expand Down

0 comments on commit d0ec9b5

Please sign in to comment.