23 lines
492 B
Go
23 lines
492 B
Go
package httpx
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func registerDocs(r *gin.Engine) {
|
|
r.GET("/openapi.yaml", func(c *gin.Context) {
|
|
c.Data(http.StatusOK, "application/yaml; charset=utf-8", openAPISpec)
|
|
})
|
|
serve := func(c *gin.Context) {
|
|
c.Data(http.StatusOK, "text/html; charset=utf-8", docsHTML)
|
|
}
|
|
r.GET("/docs", serve)
|
|
r.GET("/docs/enums", serve)
|
|
r.GET("/docs/errors", serve)
|
|
r.GET("/docs/", func(c *gin.Context) {
|
|
c.Redirect(http.StatusFound, "/docs")
|
|
})
|
|
}
|