chronograf/server/swagger.go

21 lines
520 B
Go
Raw Normal View History

2016-10-25 15:20:06 +00:00
package server
//go:generate go-bindata -o swagger_gen.go -ignore go -nocompress -pkg server .
import "net/http"
// Spec servers the swagger.json file from bindata
2016-10-25 15:20:06 +00:00
func Spec() http.HandlerFunc {
swagger, err := Asset("swagger.json")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
2016-12-20 20:59:56 +00:00
_, _ = w.Write(swagger)
2016-10-25 15:20:06 +00:00
})
}