Skip to content

Commit

Permalink
add simple fake api for _ping (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
changhr2013 authored Jun 4, 2024
1 parent c9e7d75 commit d1c19fc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ func AuthMiddleware(authToken string) gin.HandlerFunc {
}

func (s *ProxyService) InitRoutes(e *gin.Engine) {
e.GET("/_ping", s.pong)
authToken := s.cfg.AuthToken // replace with your dynamic value as needed
if authToken != "" {
// 鉴权
Expand All @@ -185,6 +186,20 @@ func (s *ProxyService) InitRoutes(e *gin.Engine) {
}
}

type Pong struct {
Now int `json:"now"`
Status string `json:"status"`
Ns1 string `json:"ns1"`
}

func (s *ProxyService) pong(c *gin.Context) {
c.JSON(http.StatusOK, Pong{
Now: time.Now().Second(),
Status: "ok",
Ns1: "200 OK",
})
}

func (s *ProxyService) completions(c *gin.Context) {
ctx := c.Request.Context()

Expand Down

0 comments on commit d1c19fc

Please sign in to comment.