diff --git a/gateway/main.go b/gateway/main.go index 138cc56..180a08a 100644 --- a/gateway/main.go +++ b/gateway/main.go @@ -8,16 +8,21 @@ import ( "context" "crypto/ecdsa" "crypto/sha256" + "embed" "encoding/base64" "encoding/hex" "encoding/json" "errors" "fmt" + "html/template" "io" "log" "net/http" "os" + + "regexp" "runtime" + "strconv" "strings" "sync" @@ -30,6 +35,23 @@ import ( "github.com/joho/godotenv" ) +//go:embed templates/swagger.html +var swaggerTemplateFS embed.FS + +var swaggerTmpl = template.Must( + template.ParseFS(swaggerTemplateFS, "templates/swagger.html"), +) + +var swaggerVersionRe = regexp.MustCompile(`^\d+\.\d+\.\d+$`) + +func getSwaggerUIVersion() string { + v := os.Getenv("SWAGGER_UI_VERSION") + if swaggerVersionRe.MatchString(v) { + return v + } + return "5.11.0" +} + type PaymentContext struct { Recipient string `json:"recipient"` Token string `json:"token"` @@ -123,26 +145,18 @@ func main() { r.StaticFile("/openapi.yaml", "openapi.yaml") r.GET("/docs", func(c *gin.Context) { - c.Header("Content-Type", "text/html") - c.String(200, ` - - -
-