Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dev_sandbox 添加 healthz 接口 #1720

Merged
merged 15 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cnb-builder-shim/internal/devsandbox/webserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func New(lg *logr.Logger) (*WebServer, error) {
AllowCredentials: corsConfig.AllowCredentials, // 凭证共享
MaxAge: 12 * time.Hour, // 预检请求缓存时间
}))
// 添加健康检查接口,不需要 token 验证
r.GET("/healthz", HealthzHandler())

// 添加 token 验证中间件
r.Use(tokenAuthMiddleware(cfg.Token))

s := &WebServer{
Expand All @@ -83,7 +87,6 @@ func New(lg *logr.Logger) (*WebServer, error) {
ch: make(chan devsandbox.AppReloadEvent),
env: cfg,
}

mgr := service.NewDeployManager()
r.POST("/deploys", DeployHandler(s, mgr))
r.GET("/deploys/:deployID/results", ResultHandler(mgr))
Expand Down Expand Up @@ -259,4 +262,11 @@ func ProcessListHandler() gin.HandlerFunc {
}
}

// HealthzHandler ...
func HealthzHandler() gin.HandlerFunc {
return func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"status": "active"})
}
}

var _ devsandbox.DevWatchServer = (*WebServer)(nil)