-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
openapi_handler.go
32 lines (30 loc) · 1012 Bytes
/
openapi_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package fuego
import (
"net/http"
)
func DefaultOpenAPIHandler(specURL string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write([]byte(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/svg+xml" href="https://go-fuego.github.io/fuego/img/logo.svg">
<title>OpenAPI specification</title>
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css" />
</head>
<body style="height: 100vh;">
<elements-api
apiDescriptionUrl="` + specURL + `"
layout="responsive"
router="hash"
logo="https://go-fuego.github.io/fuego/img/logo.svg"
tryItCredentialsPolicy="same-origin"
/>
</body>
</html>`))
})
}