merge: oapi-codegen 接线 + 生成代码入库 [tsk_Kp80nvHV2yLc]

# Conflicts:
#	server/Makefile
#	server/cmd/server/main.go
#	server/go.mod
#	server/go.sum
This commit is contained in:
wangjia
2026-06-13 17:32:25 +08:00
14 changed files with 4313 additions and 15 deletions
+8
View File
@@ -11,6 +11,9 @@ import (
"github.com/go-chi/chi/v5/middleware"
"github.com/wangjia/pangolin/server/internal/redisutil"
"github.com/wangjia/pangolin/server/internal/scheduler/probe"
"github.com/wangjia/pangolin/server/api/gen"
"github.com/wangjia/pangolin/server/internal/httpapi"
)
func main() {
@@ -29,6 +32,7 @@ func main() {
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
// Health check — outside the versioned API.
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -62,6 +66,10 @@ func main() {
log.Printf("probe ingest route registered (%d probe(s))", len(secretMap))
}
}
// Mount all /v1/... routes. HandlerFromMuxWithBaseURL registers every route
// from the OpenAPI spec onto the provided chi router with the given prefix,
// so the router itself is the http.Handler we serve.
gen.HandlerFromMuxWithBaseURL(&httpapi.UnimplementedServer{}, r, "/v1")
log.Printf("pangolin server listening on %s", *addr)
if err := http.ListenAndServe(*addr, r); err != nil {