- Updated environment configuration to unify frontend for mail and drive under a single service. - Revised README to reflect changes in frontend setup and routing for the unified application. - Introduced new API documentation endpoints for better accessibility of API specifications. - Enhanced drive and mail services with improved handling of file uploads and metadata enrichment. - Implemented new API token management features, including creation, listing, and revocation of tokens. - Added tests for new functionalities in drive and mail services to ensure reliability and correctness.
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package docs
|
|
|
|
import (
|
|
_ "embed"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
//go:embed openapi.yaml
|
|
var openAPISpec []byte
|
|
|
|
func NewHandler() *Handler {
|
|
return &Handler{}
|
|
}
|
|
|
|
type Handler struct{}
|
|
|
|
func (h *Handler) Routes() chi.Router {
|
|
r := chi.NewRouter()
|
|
r.Get("/openapi.yaml", h.serveSpec)
|
|
r.Get("/", h.serveUI)
|
|
r.Get("/*", h.serveUI)
|
|
return r
|
|
}
|
|
|
|
func (h *Handler) serveSpec(w http.ResponseWriter, _ *http.Request) {
|
|
w.Header().Set("Content-Type", "application/yaml; charset=utf-8")
|
|
w.Header().Set("Cache-Control", "public, max-age=300")
|
|
_, _ = w.Write(openAPISpec)
|
|
}
|
|
|
|
func (h *Handler) serveUI(w http.ResponseWriter, _ *http.Request) {
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
_, _ = w.Write([]byte(scalarHTML))
|
|
}
|
|
|
|
const scalarHTML = `<!doctype html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Ulti API — Documentation</title>
|
|
<style>body { margin: 0; }</style>
|
|
</head>
|
|
<body>
|
|
<script id="api-reference" data-url="/api/docs/openapi.yaml"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
</body>
|
|
</html>`
|