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:
nikhiljindal
2015-01-07 15:43:38 -08:00
parent 7bff03fb41
commit 7e909ed743
4 changed files with 93 additions and 50 deletions

View File

@@ -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))
}
}