Files
Local-Cursor/internal/backend/server/local.go
FuDie0915 db73cf5a39 chore: import Local-Cursor v1.1.8 source snapshot
Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
2026-11-10 01:24:28 +08:00

39 lines
835 B
Go

package server
import (
"net/http"
"cursor/internal/logger"
)
func Health() HandlerFunc {
return func(ctx *Context) error {
if ctx == nil || ctx.Writer == nil {
return nil
}
if ctx.Request != nil && ctx.Request.Method != http.MethodGet {
http.Error(ctx.Writer, "method not allowed", http.StatusMethodNotAllowed)
return nil
}
if ctx.Request != nil {
logger.Infof("内置后端 healthz 命中 remote_addr=%s user_agent=%s", ctx.Request.RemoteAddr, ctx.Request.UserAgent())
}
ctx.Writer.WriteHeader(http.StatusOK)
_, _ = ctx.Writer.Write([]byte("ok"))
return nil
}
}
func HTTPHandlerAction(handler http.Handler) HandlerFunc {
return func(ctx *Context) error {
if ctx == nil {
return nil
}
if handler == nil {
return nil
}
handler.ServeHTTP(ctx.Writer, ctx.Request)
return nil
}
}