MCPcopy Create free account
hub / github.com/dolanor/rip / handleSwaggerUI

Function handleSwaggerUI

openapi.go:33–55  ·  view source on GitHub ↗
(title string)

Source from the content-addressed store, hash-verified

31}
32
33func handleSwaggerUI(title string) http.HandlerFunc {
34 return func(w http.ResponseWriter, r *http.Request) {
35 w.Header().Set("Content-Type", "text/html")
36 tmpl, err := template.New("swagger-ui").Parse(swaggerUITemplate)
37 if err != nil {
38 http.Error(w, "Error rendering UI template", http.StatusInternalServerError)
39 return
40 }
41
42 data := struct {
43 Title string
44 Path string
45 }{
46 Title: title,
47 Path: "/api-docs/swagger.json",
48 }
49
50 err = tmpl.Execute(w, data)
51 if err != nil {
52 http.Error(w, "Error rendering UI template", http.StatusInternalServerError)
53 }
54 }
55}

Callers 1

NewRouterFunction · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected