refactor(api): move Swagger UI to docs route
This commit is contained in:
@@ -34,8 +34,8 @@ const swaggerUI = `<!doctype html>
|
||||
// RegisterDocumentation registers the OpenAPI document and its Swagger UI.
|
||||
func RegisterDocumentation(mux *http.ServeMux) {
|
||||
mux.HandleFunc("GET /openapi.json", serveOpenAPI)
|
||||
mux.HandleFunc("GET /swagger/", serveSwaggerUI)
|
||||
mux.HandleFunc("GET /docs", redirectToSwaggerUI)
|
||||
mux.HandleFunc("GET /docs/", serveSwaggerUI)
|
||||
mux.HandleFunc("GET /docs", redirectToDocumentation)
|
||||
}
|
||||
|
||||
func serveOpenAPI(w http.ResponseWriter, _ *http.Request) {
|
||||
@@ -48,6 +48,6 @@ func serveSwaggerUI(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte(swaggerUI))
|
||||
}
|
||||
|
||||
func redirectToSwaggerUI(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/swagger/", http.StatusTemporaryRedirect)
|
||||
func redirectToDocumentation(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/docs/", http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user