Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xu756 committed Oct 7, 2024
1 parent 57648df commit 0d671cf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/api/router/init.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package router

import (
"context"
"github.com/cloudwego/hertz/pkg/app"
"github.com/hertz-contrib/obs-opentelemetry/tracing"
"imlogic/app/api/logic"
"imlogic/common/config"
"imlogic/internal/middleware"
"imlogic/internal/result"

"github.com/cloudwego/hertz/pkg/app/server"
)
Expand Down Expand Up @@ -34,5 +37,14 @@ func InitRouter() {
friendRouter := router.Group("/friend")
logic.FriendRoute(friendRouter)
friendRouter.Use(middleware.HertzJwt())
router.GET("/ping", func(ctx context.Context, c *app.RequestContext) {
header := make(map[string]string)
c.VisitAllHeaders(func(key, value []byte) {
header[string(key)] = string(value)
})
header["RemoteAddr"] = c.RemoteAddr().String()
header["ip"] = c.ClientIP()
result.HttpSuccess(c, header)
})
HttpServer = h
}

0 comments on commit 0d671cf

Please sign in to comment.