common.go 792 B

1234567891011121314151617181920212223242526272829303132
  1. package routes
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // RegisterCommonRoutes 注册通用路由(健康检查、状态等)
  7. func RegisterCommonRoutes(r *gin.Engine) {
  8. // 健康检查
  9. r.GET("/health", func(c *gin.Context) {
  10. c.JSON(http.StatusOK, gin.H{"status": "ok"})
  11. })
  12. // Claude Code 遥测日志(忽略,直接返回200)
  13. r.POST("/api/event_logging/batch", func(c *gin.Context) {
  14. c.Status(http.StatusOK)
  15. })
  16. // Setup status endpoint (always returns needs_setup: false in normal mode)
  17. // This is used by the frontend to detect when the service has restarted after setup
  18. r.GET("/setup/status", func(c *gin.Context) {
  19. c.JSON(http.StatusOK, gin.H{
  20. "code": 0,
  21. "data": gin.H{
  22. "needs_setup": false,
  23. "step": "completed",
  24. },
  25. })
  26. })
  27. }