mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 05:01:46 +00:00
Changes to improve swagger ui.
- Separating out index, version and api handlers into independent web services. Moved the index handler to /welcome, version handler to /version and the api handler to /api,
This commit is contained in:
@@ -26,14 +26,16 @@ type MuxInterface interface {
|
||||
Handle(pattern string, handler http.Handler)
|
||||
}
|
||||
|
||||
func InstallSupport(mux MuxInterface) {
|
||||
func InstallSupport(mux MuxInterface, enableSwaggerSupport bool) {
|
||||
// Expose files in www/ on <host>/static/
|
||||
fileServer := http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "www"})
|
||||
prefix := "/static/"
|
||||
mux.Handle(prefix, http.StripPrefix(prefix, fileServer))
|
||||
|
||||
// Expose files in third_party/swagger-ui/ on <host>/swagger-ui/
|
||||
fileServer = http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "third_party/swagger-ui"})
|
||||
prefix = "/swagger-ui/"
|
||||
mux.Handle(prefix, http.StripPrefix(prefix, fileServer))
|
||||
if enableSwaggerSupport {
|
||||
// Expose files in third_party/swagger-ui/ on <host>/swagger-ui
|
||||
fileServer = http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "third_party/swagger-ui"})
|
||||
prefix = "/swagger-ui/"
|
||||
mux.Handle(prefix, http.StripPrefix(prefix, fileServer))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user