mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 19:39:02 +08:00
feat: onboarding API via proxy (#6058)
* feat: onboarding API via proxy * chore: update profiles route * chore: update profiles url
This commit is contained in:
parent
fc4b55cb34
commit
337a941d0d
@ -9,7 +9,15 @@ import (
|
|||||||
|
|
||||||
func (ah *APIHandler) ServeGatewayHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (ah *APIHandler) ServeGatewayHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
ctx := req.Context()
|
ctx := req.Context()
|
||||||
if !strings.HasPrefix(req.URL.Path, gateway.RoutePrefix+gateway.AllowedPrefix) {
|
validPath := false
|
||||||
|
for _, allowedPrefix := range gateway.AllowedPrefix {
|
||||||
|
if strings.HasPrefix(req.URL.Path, gateway.RoutePrefix+allowedPrefix) {
|
||||||
|
validPath = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !validPath {
|
||||||
rw.WriteHeader(http.StatusNotFound)
|
rw.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var (
|
||||||
RoutePrefix string = "/api/gateway"
|
RoutePrefix string = "/api/gateway"
|
||||||
AllowedPrefix string = "/v1/workspaces/me"
|
AllowedPrefix []string = []string{"/v1/workspaces/me", "/v2/profiles/me"}
|
||||||
)
|
)
|
||||||
|
|
||||||
type proxy struct {
|
type proxy struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user