Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
35 lines
735 B
Go
35 lines
735 B
Go
package api
|
|
|
|
import (
|
|
_ "embed"
|
|
"net/http"
|
|
)
|
|
|
|
//go:embed swagger.json
|
|
var swaggerSpec []byte
|
|
|
|
//go:embed swagger-ui.html
|
|
var swaggerUI []byte
|
|
|
|
func (s *Server) handleSwaggerJSON(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
methodNotAllowed(w)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
w.Write(swaggerSpec)
|
|
}
|
|
|
|
func (s *Server) handleSwaggerUI(w http.ResponseWriter, r *http.Request) {
|
|
if r.URL.Path != "/" {
|
|
http.NotFound(w, r)
|
|
return
|
|
}
|
|
if r.Method != http.MethodGet {
|
|
methodNotAllowed(w)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
w.Write(swaggerUI)
|
|
}
|