Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Handler = func(prefix string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet || path.Base(r.URL.Path) != "swagger-initializer.js" { http.StripPrefix(prefix, http.FileServer(http.FS(assets))).ServeHTTP(w, r) return } tpl := template.New("swagger-initializer.js").Funcs(TemplateFuncs) ptpl, err := tpl.Parse(Template) if err != nil { w.WriteHeader(http.StatusInternalServerError) _, _ = w.Write([]byte(err.Error())) return } if err := ptpl.Execute(w, Config); err != nil { w.WriteHeader(http.StatusInternalServerError) _, _ = w.Write([]byte(err.Error())) return } } } TemplateFuncs = template.FuncMap{ "isInt": func(i interface{}) bool { v := reflect.ValueOf(i) switch v.Kind() { case reflect.Int, reflect.Int8, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64: return true default: return false } }, "isBool": func(i interface{}) bool { v := reflect.ValueOf(i) switch v.Kind() { case reflect.Bool: return true default: return false } }, "isString": func(i interface{}) bool { v := reflect.ValueOf(i) switch v.Kind() { case reflect.String: return true default: return false } }, "isSlice": func(i interface{}) bool { v := reflect.ValueOf(i) switch v.Kind() { case reflect.Slice: return true default: return false } }, "isMap": func(i interface{}) bool { v := reflect.ValueOf(i) switch v.Kind() { case reflect.Map: return true default: return false } }, } Template = `` /* 584-byte string literal not displayed */ Config = map[string]interface{}{ "configUrl": "", "dom_id": "#swagger-ui", "url": "https://petstore.swagger.io/v2/swagger.json", "deepLinking": true, "displayOperationId": false, "defaultModelsExpandDepth": 1, "defaultModelExpandDepth": 1, "displayRequestDuration": true, "filter": true, "operationsSorter": "alpha", "showExtensions": true, "tryItOutEnabled": true, "presets": []string{ "SwaggerUIBundle.presets.apis", "SwaggerUIStandalonePreset", }, "plugins": []string{ "SwaggerUIBundle.plugins.DownloadUrl", }, "layout": "StandaloneLayout", } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.