app_api.go 682 B

12345678910111213141516171819202122232425262728293031
  1. package route
  2. import (
  3. // m "git.llsapp.com/zhenghe/pkg/http/middleware"
  4. "kpt-grpc-demo/http/api"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func AppAPI(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
  8. return func(s *gin.Engine) {
  9. for _, opt := range opts {
  10. opt(s)
  11. }
  12. // Not Found
  13. s.NoRoute(api.Handle404)
  14. // Health Check
  15. s.GET("/check", api.Health)
  16. // lingo API 组
  17. lingoRoute := authRouteGroup(s, "/api/v1/kpt/")
  18. lingoRoute.GET("/hello", api.Hello)
  19. }
  20. }
  21. func authRouteGroup(s *gin.Engine, relativePath string) *gin.RouterGroup {
  22. group := s.Group(relativePath)
  23. // TODO 中间件鉴权
  24. // group.Use(middleware.Auth(), m.UserKitMiddleware())
  25. return group
  26. }