mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix static path matching issue in macaron (#40023)
Co-authored-by: Malcolm Holmes <mdh@odoko.co.uk>
This commit is contained in:
committed by
GitHub
parent
feaa56a7fe
commit
329f96db1a
@@ -147,6 +147,10 @@ func CreateDashboardSnapshot(c *models.ReqContext, cmd models.CreateDashboardSna
|
|||||||
// GET /api/snapshots/:key
|
// GET /api/snapshots/:key
|
||||||
func GetDashboardSnapshot(c *models.ReqContext) response.Response {
|
func GetDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||||
key := macaron.Params(c.Req)[":key"]
|
key := macaron.Params(c.Req)[":key"]
|
||||||
|
if len(key) == 0 {
|
||||||
|
return response.Error(404, "Snapshot not found", nil)
|
||||||
|
}
|
||||||
|
|
||||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||||
|
|
||||||
err := bus.Dispatch(query)
|
err := bus.Dispatch(query)
|
||||||
@@ -211,6 +215,9 @@ func deleteExternalDashboardSnapshot(externalUrl string) error {
|
|||||||
// GET /api/snapshots-delete/:deleteKey
|
// GET /api/snapshots-delete/:deleteKey
|
||||||
func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response {
|
func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response {
|
||||||
key := macaron.Params(c.Req)[":deleteKey"]
|
key := macaron.Params(c.Req)[":deleteKey"]
|
||||||
|
if len(key) == 0 {
|
||||||
|
return response.Error(404, "Snapshot not found", nil)
|
||||||
|
}
|
||||||
|
|
||||||
query := &models.GetDashboardSnapshotQuery{DeleteKey: key}
|
query := &models.GetDashboardSnapshotQuery{DeleteKey: key}
|
||||||
|
|
||||||
@@ -241,6 +248,9 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
|
|||||||
// DELETE /api/snapshots/:key
|
// DELETE /api/snapshots/:key
|
||||||
func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||||
key := macaron.Params(c.Req)[":key"]
|
key := macaron.Params(c.Req)[":key"]
|
||||||
|
if len(key) == 0 {
|
||||||
|
return response.Error(404, "Snapshot not found", nil)
|
||||||
|
}
|
||||||
|
|
||||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||||
|
|
||||||
|
|||||||
@@ -207,10 +207,12 @@ func (r *Router) NotFound(handlers ...Handler) {
|
|||||||
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
if t, ok := r.routers[req.Method]; ok {
|
if t, ok := r.routers[req.Method]; ok {
|
||||||
// Fast match for static routes
|
// Fast match for static routes
|
||||||
leaf := r.getLeaf(req.Method, req.URL.Path)
|
if !strings.ContainsAny(req.URL.Path, ":*") {
|
||||||
if leaf != nil {
|
leaf := r.getLeaf(req.Method, req.URL.Path)
|
||||||
leaf.handle(rw, req, nil)
|
if leaf != nil {
|
||||||
return
|
leaf.handle(rw, req, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h, p, ok := t.Match(req.URL.EscapedPath())
|
h, p, ok := t.Match(req.URL.EscapedPath())
|
||||||
|
|||||||
Reference in New Issue
Block a user