Skip to content

Commit

Permalink
On the way to v1 parity #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed Dec 13, 2024
1 parent 9e47844 commit 02e514f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
28 changes: 23 additions & 5 deletions quesma/frontend_connectors/basic_http_frontend_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ func (h *BasicHTTPFrontendConnector) ServeHTTP(w http.ResponseWriter, req *http.
QueryParams: req.URL.Query(),
Body: string(reqBody),
}
handlerWrapper, _ := h.router.Matches(quesmaRequest)
handlersPipe, decision := h.router.Matches(quesmaRequest)
if decision != nil {
w.Header().Set(QuesmaTableResolverHeader, decision.String())
} else {
w.Header().Set(QuesmaTableResolverHeader, "n/a")
}
dispatcher := &quesma_api.Dispatcher{}
w = h.responseMutator(w)
if handlerWrapper == nil {
if handlersPipe == nil {
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if h.router.GetFallbackHandler() != nil {
fmt.Printf("No handler found for path: %s\n", req.URL.Path)
Expand All @@ -74,10 +79,23 @@ func (h *BasicHTTPFrontendConnector) ServeHTTP(w http.ResponseWriter, req *http.
return
}
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
result, _ := handlerWrapper.Handler(context.Background(), &quesma_api.Request{OriginalRequest: req})
result, _ := handlersPipe.Handler(context.Background(), &quesma_api.Request{OriginalRequest: req})

metadata, message := dispatcher.Dispatch(handlersPipe.Processors, result.Meta, result.GenericResult)
result = &quesma_api.Result{
Body: result.Body,
Meta: metadata,
StatusCode: result.StatusCode,
GenericResult: message,
}
zip := strings.Contains(req.Header.Get("Accept-Encoding"), "gzip")
_ = zip
if err == nil {

_, message := dispatcher.Dispatch(handlerWrapper.Processors, result.Meta, result.GenericResult)
_, err := w.Write(message.([]byte))
} else {

}
_, err := w.Write(result.GenericResult.([]byte))
if err != nil {
fmt.Printf("Error writing response: %s\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion quesma/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func constructQuesma(cfg *config.QuesmaConfiguration, sl clickhouse.TableDiscove
if cfg.TransparentProxy {
return quesma.NewQuesmaTcpProxy(phoneHomeAgent, cfg, quesmaManagementConsole, logChan, false)
} else {
const quesma_v2 = false
const quesma_v2 = true
return quesma.NewHttpProxy(phoneHomeAgent, lm, ip, sl, im, schemaRegistry, cfg, quesmaManagementConsole, abResultsrepository, indexRegistry, quesma_v2)
}
}

0 comments on commit 02e514f

Please sign in to comment.