package headscale import ( "bytes" _ "embed" "html/template" "net/http" "github.com/gin-gonic/gin" "github.com/rs/zerolog/log" ) //go:embed gen/openapiv2/headscale/v1/headscale.swagger.json var apiV1JSON []byte func SwaggerUI(ctx *gin.Context) { swaggerTemplate := template.Must(template.New("swagger").Parse(`
`)) var payload bytes.Buffer if err := swaggerTemplate.Execute(&payload, struct{}{}); err != nil { log.Error(). Caller(). Err(err). Msg("Could not render Swagger") ctx.Data( http.StatusInternalServerError, "text/html; charset=utf-8", []byte("Could not render Swagger"), ) return } ctx.Data(http.StatusOK, "text/html; charset=utf-8", payload.Bytes()) } func SwaggerAPIv1(ctx *gin.Context) { ctx.Data(http.StatusOK, "application/json; charset=utf-8", apiV1JSON) }