mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-12-06 05:07:25 +08:00
20 lines
511 B
Go
20 lines
511 B
Go
package api
|
|
|
|
import (
|
|
_ "embed"
|
|
"log/slog"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed admin.yaml
|
|
var adminYAML []byte
|
|
|
|
func ServeAdminSpec(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/yaml")
|
|
w.Header().Set("Content-Disposition", `attachment; filename="admin.yaml"`)
|
|
w.Header().Set("Cache-Control", "private, no-store")
|
|
if _, err := w.Write(adminYAML); err != nil && r.Context().Err() == nil {
|
|
slog.WarnContext(r.Context(), "写入后台 OpenAPI 文档失败", "error", err)
|
|
}
|
|
}
|