add simple fake api for _ping (#34)
This commit is contained in:
parent
c9e7d75fec
commit
d1c19fc7ef
15
main.go
15
main.go
|
|
@ -171,6 +171,7 @@ func AuthMiddleware(authToken string) gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProxyService) InitRoutes(e *gin.Engine) {
|
func (s *ProxyService) InitRoutes(e *gin.Engine) {
|
||||||
|
e.GET("/_ping", s.pong)
|
||||||
authToken := s.cfg.AuthToken // replace with your dynamic value as needed
|
authToken := s.cfg.AuthToken // replace with your dynamic value as needed
|
||||||
if authToken != "" {
|
if authToken != "" {
|
||||||
// 鉴权
|
// 鉴权
|
||||||
|
|
@ -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) {
|
func (s *ProxyService) completions(c *gin.Context) {
|
||||||
ctx := c.Request.Context()
|
ctx := c.Request.Context()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue