Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 1d82268

Browse files
authored
PathMutex missing features (#1088)
1 parent 88033c1 commit 1d82268

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

quesma/frontend_connectors/basic_http_frontend_connector.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ import (
1515
)
1616

1717
type HTTPRouter struct {
18-
mux *http.ServeMux // Default HTTP multiplexer
1918
handlers map[string]quesma_api.HandlersPipe // Map to store custom route handlers
2019
fallbackHandler quesma_api.HTTPFrontendHandler
2120
mutex sync.RWMutex // Mutex for concurrent access to handlers
2221
}
2322

2423
func NewHTTPRouter() *HTTPRouter {
2524
return &HTTPRouter{
26-
mux: http.NewServeMux(),
2725
handlers: make(map[string]quesma_api.HandlersPipe),
2826
}
2927
}

quesma/frontend_connectors/elasticsearch_ingest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func NewElasticsearchIngestFrontendConnector(endpoint string) *ElasticsearchInge
3333
responseMutator: setContentType,
3434
},
3535
}
36-
router := NewHTTPRouter()
36+
router := quesma_api.NewPathRouter()
3737
router.AddRoute(IndexBulkPath, bulk)
3838
router.AddRoute(IndexDocPath, doc)
3939
fc.AddRouter(router)

quesma/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func ab_testing_scenario() quesma_api.QuesmaBuilder {
6464
var quesmaBuilder quesma_api.QuesmaBuilder = quesma_api.NewQuesma()
6565

6666
ingestFrontendConnector := frontend_connectors.NewBasicHTTPFrontendConnector(":8888")
67-
ingestHTTPRouter := frontend_connectors.NewHTTPRouter()
67+
ingestHTTPRouter := quesma_api.NewPathRouter()
6868
ingestHTTPRouter.AddRoute("/_bulk", bulk)
6969
ingestHTTPRouter.AddRoute("/_doc", doc)
7070
ingestFrontendConnector.AddRouter(ingestHTTPRouter)
@@ -82,7 +82,7 @@ func ab_testing_scenario() quesma_api.QuesmaBuilder {
8282
ingestPipeline.AddProcessor(abIngestTestProcessor)
8383

8484
queryFrontendConnector := frontend_connectors.NewBasicHTTPFrontendConnector(":8888")
85-
queryHTTPRouter := frontend_connectors.NewHTTPRouter()
85+
queryHTTPRouter := quesma_api.NewPathRouter()
8686
queryHTTPRouter.AddRoute("/_search", search)
8787
queryFrontendConnector.AddRouter(queryHTTPRouter)
8888
var queryPipeline quesma_api.PipelineBuilder = quesma_api.NewPipeline()

quesma/v2/core/mux.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"github.com/ucarion/urlpath"
77
"net/http"
88
"net/url"
9-
109
"strings"
1110
)
1211

1312
type (
1413
PathRouter struct {
15-
mappings []mapping
14+
mappings []mapping
15+
fallbackHandler HTTPFrontendHandler
1616
}
1717
mapping struct {
1818
pattern string
@@ -92,7 +92,6 @@ func (p *PathRouter) Clone() Cloner {
9292
}
9393

9494
func (p *PathRouter) Register(pattern string, predicate RequestMatcher, handler HTTPFrontendHandler) {
95-
9695
mapping := mapping{pattern, urlpath.New(pattern), predicate, &HandlersPipe{Handler: handler}}
9796
p.mappings = append(p.mappings, mapping)
9897

@@ -186,15 +185,13 @@ func Always() RequestMatcher {
186185
}
187186

188187
func (p *PathRouter) AddRoute(path string, handler HTTPFrontendHandler) {
189-
// TODO: it seems that we can adapt this to register call
190-
// p.Register(path, Always(), handler)
191-
panic("not implemented")
188+
p.Register(path, Always(), handler)
192189
}
193190
func (p *PathRouter) AddFallbackHandler(handler HTTPFrontendHandler) {
194-
panic("not implemented")
191+
p.fallbackHandler = handler
195192
}
196193
func (p *PathRouter) GetFallbackHandler() HTTPFrontendHandler {
197-
panic("not implemented")
194+
return p.fallbackHandler
198195
}
199196
func (p *PathRouter) GetHandlers() map[string]HandlersPipe {
200197
callInfos := make(map[string]HandlersPipe)

0 commit comments

Comments
 (0)