local-server/vendor/github.com/mcluseau/go-swagger-ui/ui.go

21 lines
380 B
Go
Raw Normal View History

2019-02-04 02:56:43 +00:00
package swaggerui
import (
"net/http"
"github.com/gobuffalo/packr"
)
// Box returns the Swagger UI packr box
func Box() packr.Box {
return packr.NewBox("./swagger-ui/dist")
}
// HandleAt sets up a http handle at the given path
func HandleAt(path string) {
if path[len(path)-1] != '/' {
path += "/"
}
http.Handle(path, http.StripPrefix(path, http.FileServer(Box())))
}