API: Extract OpenAPI specification from source code using go-swagger (#40528)
* API: Using go-swagger for extracting OpenAPI specification from source code * Merge Grafana Alerting spec * Include enterprise endpoints (if enabled) * Serve SwaggerUI under feature flag * Fix building dev docker images * Configure swaggerUI * Add missing json tags Co-authored-by: Ying WANG <ying.wang@grafana.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
co-authored by
Ying WANG
Marcus Efraimsson
parent
9c2363ef08
commit
35fe58de37
@@ -446,7 +446,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
m.Use(middleware.Recovery(hs.Cfg))
|
||||
|
||||
hs.mapStatic(m, hs.Cfg.StaticRootPath, "build", "public/build")
|
||||
hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public")
|
||||
hs.mapStatic(m, hs.Cfg.StaticRootPath, "", "public", "/public/views/swagger.html")
|
||||
hs.mapStatic(m, hs.Cfg.StaticRootPath, "robots.txt", "robots.txt")
|
||||
|
||||
if hs.Cfg.ImageUploadProvider == "local" {
|
||||
@@ -553,7 +553,7 @@ func (hs *HTTPServer) apiHealthHandler(ctx *web.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) mapStatic(m *web.Mux, rootDir string, dir string, prefix string) {
|
||||
func (hs *HTTPServer) mapStatic(m *web.Mux, rootDir string, dir string, prefix string, exclude ...string) {
|
||||
headers := func(c *web.Context) {
|
||||
c.Resp.Header().Set("Cache-Control", "public, max-age=3600")
|
||||
}
|
||||
@@ -576,6 +576,7 @@ func (hs *HTTPServer) mapStatic(m *web.Mux, rootDir string, dir string, prefix s
|
||||
SkipLogging: true,
|
||||
Prefix: prefix,
|
||||
AddHeaders: headers,
|
||||
Exclude: exclude,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user