diff --git a/docs/openapi/openapi.go b/docs/openapi/openapi.go index 187dbbe7ce..9dc621b6ae 100644 --- a/docs/openapi/openapi.go +++ b/docs/openapi/openapi.go @@ -2,22 +2,21 @@ package openapi import ( "embed" - "html/template" "net/http" "github.com/gorilla/mux" ) const ( - apiFile = "openapi.swagger.yaml" - templateFile = "template.tpl" + apiFile = "openapi.swagger.yaml" + htmlFile = "openapi.html" ) //go:embed openapi.swagger.yaml var staticFS embed.FS -//go:embed template.tpl -var templateFS embed.FS +//go:embed openapi.html +var html []byte func RegisterOpenAPIService(router *mux.Router) { router.Handle("/"+apiFile, http.FileServer(http.FS(staticFS))) @@ -25,19 +24,8 @@ func RegisterOpenAPIService(router *mux.Router) { } func openAPIHandler() http.HandlerFunc { - tmpl, err := template.ParseFS(templateFS, templateFile) - if err != nil { - panic(err) - } - return func(w http.ResponseWriter, _ *http.Request) { - err := tmpl.Execute(w, struct { - URL string - }{ - "/" + apiFile, - }) - if err != nil { - http.Error(w, "Failed to render template", http.StatusInternalServerError) - } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.Write(html) } } diff --git a/docs/openapi/template.tpl b/docs/openapi/openapi.html similarity index 94% rename from docs/openapi/template.tpl rename to docs/openapi/openapi.html index 63b89df478..37fbfb2a16 100644 --- a/docs/openapi/template.tpl +++ b/docs/openapi/openapi.html @@ -20,7 +20,7 @@