package middleware import ( "bytes" "fmt" "net/http" "text/template" ) func SwaggerUIOAuth2Callback(opts SwaggerUIOpts, next http.Handler) http.Handler { opts.EnsureDefaultsOauth2() pth := opts.OAuthCallbackURL tmpl := template.Must(template.New("swaggeroauth").Parse(opts.Template)) assets := bytes.NewBuffer(nil) if err := tmpl.Execute(assets, opts); err != nil { panic(fmt.Errorf("cannot execute template: %w", err)) } return serveUI(pth, assets.Bytes(), next) } const ( swaggerOAuthTemplate = ` {{ .Title }} ` )