mirror of
https://github.com/Warky-Devs/vecna.git
synced 2026-05-05 01:26:58 +00:00
feat: 🎉 Vectors na Vectors, the begining
Translate 1536 <-> 768 , 3072 <-> 2048
This commit is contained in:
36
pkg/server/spec/handler.go
Normal file
36
pkg/server/spec/handler.go
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user