Skip to content

Commit

Permalink
allow proxying of database and default_format params
Browse files Browse the repository at this point in the history
  • Loading branch information
r.khavronenko committed Oct 26, 2017
1 parent 8ea2ea7 commit 42a07c8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,24 @@ func (s *scope) killQuery() error {
return nil
}

var allowedParams = []string{
"query",
"database",
"default_format",
}

func (s *scope) decorateRequest(req *http.Request) *http.Request {
// make new params to purify URL
params := make(url.Values)

// set query_id as scope_id to have possibility kill query if needed
params.Set("query_id", fmt.Sprintf("%X", s.id))
// if query was passed - keep it
q := req.URL.Query().Get("query")
if len(q) > 0 {
params.Set("query", q)
for _, param := range allowedParams {
val := req.URL.Query().Get(param)
if len(val) > 0 {
params.Set(param, val)
}
}
req.URL.RawQuery = params.Encode()

Expand Down

0 comments on commit 42a07c8

Please sign in to comment.