Files
vecna/pkg/server/spec/handler.go
Hein 4009a54e39 feat: 🎉 Vectors na Vectors, the begining
Translate 1536 <-> 768 , 3072 <-> 2048
2026-04-11 18:05:05 +02:00

37 lines
909 B
Go

package spec
import (
_ "embed"
"net/http"
"github.com/uptrace/bunrouter"
)
//go:embed openapi.yaml
var openapiYAML []byte
// SpecHandler serves the raw OpenAPI YAML spec.
func SpecHandler() bunrouter.HandlerFunc {
return func(w http.ResponseWriter, req bunrouter.Request) error {
w.Header().Set("Content-Type", "application/yaml")
_, err := w.Write(openapiYAML)
return err
}
}
// DocsHandler serves the Scalar API reference UI.
func DocsHandler() bunrouter.HandlerFunc {
return func(w http.ResponseWriter, req bunrouter.Request) error {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, err := w.Write([]byte(`<!doctype html>
<html>
<head><title>vecna API</title><meta charset="utf-8"/></head>
<body>
<script id="api-reference" data-url="/openapi.yaml"></script>
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
</body>
</html>`))
return err
}
}