From 229b79281bdf5d564f459a4092d0e2f006abfae9 Mon Sep 17 00:00:00 2001 From: Brett Buddin Date: Fri, 8 May 2020 09:03:21 -0400 Subject: [PATCH] feat(http): Allow query handlers to be proxied for Algo-W testing. --- http/query_handler.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/http/query_handler.go b/http/query_handler.go index 0d1fd5a0b5..23e183bdfd 100644 --- a/http/query_handler.go +++ b/http/query_handler.go @@ -46,6 +46,7 @@ type FluxBackend struct { log *zap.Logger QueryEventRecorder metric.EventRecorder + AlgoWProxy FeatureProxyHandler OrganizationService influxdb.OrganizationService ProxyQueryService query.ProxyQueryService } @@ -56,7 +57,7 @@ func NewFluxBackend(log *zap.Logger, b *APIBackend) *FluxBackend { HTTPErrorHandler: b.HTTPErrorHandler, log: log, QueryEventRecorder: b.QueryEventRecorder, - + AlgoWProxy: b.AlgoWProxy, ProxyQueryService: routingQueryService{ InfluxQLService: b.InfluxQLService, DefaultService: b.FluxService, @@ -103,11 +104,11 @@ func NewFluxHandler(log *zap.Logger, b *FluxBackend) *FluxHandler { // query reponses can optionally be gzip encoded qh := gziphandler.GzipHandler(http.HandlerFunc(h.handleQuery)) - h.Handler("POST", prefixQuery, qh) - h.HandlerFunc("POST", "/api/v2/query/ast", h.postFluxAST) - h.HandlerFunc("POST", "/api/v2/query/analyze", h.postQueryAnalyze) - h.HandlerFunc("GET", "/api/v2/query/suggestions", h.getFluxSuggestions) - h.HandlerFunc("GET", "/api/v2/query/suggestions/:name", h.getFluxSuggestion) + h.Handler("POST", prefixQuery, withFeatureProxy(b.AlgoWProxy, qh)) + h.Handler("POST", "/api/v2/query/ast", withFeatureProxy(b.AlgoWProxy, http.HandlerFunc(h.postFluxAST))) + h.Handler("POST", "/api/v2/query/analyze", withFeatureProxy(b.AlgoWProxy, http.HandlerFunc(h.postQueryAnalyze))) + h.Handler("GET", "/api/v2/query/suggestions", withFeatureProxy(b.AlgoWProxy, http.HandlerFunc(h.getFluxSuggestions))) + h.Handler("GET", "/api/v2/query/suggestions/:name", withFeatureProxy(b.AlgoWProxy, http.HandlerFunc(h.getFluxSuggestion))) return h }