-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): filter with expression language #682
Conversation
@@ -160,9 +213,18 @@ func (resp QueryMeterResponse) Render(_ http.ResponseWriter, _ *http.Request) er | |||
} | |||
|
|||
// RenderCSV renders the response as CSV. | |||
func (resp QueryMeterResponse) RenderCSV(w http.ResponseWriter, r *http.Request, groupByKeys []string, meterIDOrSlug string) { | |||
func (resp QueryMeterResponse) RenderCSV(w http.ResponseWriter, r *http.Request, _groupByKeys []string, meterIDOrSlug string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func (resp QueryMeterResponse) RenderCSV(w http.ResponseWriter, r *http.Request, _groupByKeys []string, meterIDOrSlug string) { | |
func (resp QueryMeterResponse) RenderCSV(w http.ResponseWriter, r *http.Request, groupByKeys []string, meterIDOrSlug string) { |
records := [][]string{} | ||
|
||
// Filter out the subject from the group by keys | ||
groupByKeys := []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groupByKeys := []string{} | |
dataGroupByKeys := make([]string, 0, len(groupByKeys)) |
The slice will have at most the same length as groupByKeys
if k == "subject" { | ||
continue | ||
} | ||
groupByKeys = append(groupByKeys, k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groupByKeys = append(groupByKeys, k) | |
dataGroupByKeys = append(dataGroupByKeys, k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the file name :) filLter.go
Closing due to inactivity |
Example
http://localhost:8888/api/v1/meters/api_requests_total/query?windowSize=HOUR&groupBy=route&groupBy=subject&groupBy=method&filter[subject]={"$in":["customer-1","customer-2"]}&filter[route]={"$eq":"/hello"}&filter[method]={"$nin":["POST","DELETE"]}`
One of the biggest values of JSON-based filters is that we can validate them with OpenAPI. However, for some reason, this validation doesn't work for query params. It works if it's a POST payload.