Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3fa80881
Unverified
Commit
3fa80881
authored
Oct 03, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dataproxy should forward a trailing slash to proxy
parent
8bf4d680
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
pkg/api/dataproxy.go
+12
-8
pkg/api/dataproxy_test.go
+19
-0
No files found.
pkg/api/dataproxy.go
View file @
3fa80881
...
@@ -51,17 +51,21 @@ func (hs *HTTPServer) ProxyDataSourceRequest(c *m.ReqContext) {
...
@@ -51,17 +51,21 @@ func (hs *HTTPServer) ProxyDataSourceRequest(c *m.ReqContext) {
return
return
}
}
proxyPath
:=
c
.
Params
(
"*"
)
// Check for a trailing slash, and pass it to the proxy
// macaron does not include trailing slashes when resolving a wildcard path
// macaron does not include trailing slashes when resolving a wildcard path
proxyPath
:=
ensureProxyPathTrailingSlash
(
c
.
Req
.
URL
.
Path
,
c
.
Params
(
"*"
))
proxy
:=
pluginproxy
.
NewDataSourceProxy
(
ds
,
plugin
,
c
,
proxyPath
)
proxy
.
HandleRequest
()
}
// ensureProxyPathTrailingSlash Check for a trailing slash in original path and makes
// sure that a trailing slash is added to proxy path, if not already exists.
func
ensureProxyPathTrailingSlash
(
originalPath
,
proxyPath
string
)
string
{
if
len
(
proxyPath
)
>
1
{
if
len
(
proxyPath
)
>
1
{
path
:=
c
.
Req
.
URL
.
Path
if
originalPath
[
len
(
originalPath
)
-
1
]
==
'/'
&&
proxyPath
[
len
(
proxyPath
)
-
1
]
!=
'/'
{
if
path
[
len
(
path
)
-
1
]
==
'/'
&&
proxyPath
[
len
(
proxyPath
)
-
1
]
!=
'/'
{
return
proxyPath
+
"/"
proxyPath
+=
"/"
}
}
}
}
proxy
:=
pluginproxy
.
NewDataSourceProxy
(
ds
,
plugin
,
c
,
proxyPath
)
return
proxyPath
proxy
.
HandleRequest
()
}
}
pkg/api/dataproxy_test.go
0 → 100644
View file @
3fa80881
package
api
import
(
"testing"
.
"github.com/smartystreets/goconvey/convey"
)
func
TestDataProxy
(
t
*
testing
.
T
)
{
Convey
(
"Data proxy test"
,
t
,
func
()
{
Convey
(
"Should append trailing slash to proxy path if original path has a trailing slash"
,
func
()
{
So
(
ensureProxyPathTrailingSlash
(
"/api/datasources/proxy/6/api/v1/query_range/"
,
"api/v1/query_range/"
),
ShouldEqual
,
"api/v1/query_range/"
)
})
Convey
(
"Should not append trailing slash to proxy path if original path doesn't have a trailing slash"
,
func
()
{
So
(
ensureProxyPathTrailingSlash
(
"/api/datasources/proxy/6/api/v1/query_range"
,
"api/v1/query_range"
),
ShouldEqual
,
"api/v1/query_range"
)
})
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment