Skip to content

Make REST router more like a map and allow overwriting routes#2403

Merged
stephenberry merged 1 commit intomainfrom
rest-registry-route-overwriting
Mar 26, 2026
Merged

Make REST router more like a map and allow overwriting routes#2403
stephenberry merged 1 commit intomainfrom
rest-registry-route-overwriting

Conversation

@stephenberry
Copy link
Copy Markdown
Owner

@stephenberry stephenberry commented Mar 26, 2026

Fix route conflict error on REST service composition (#2401)

Registering multiple services on a single glz::registry<opts, REST> via separate on() calls produced spurious "Route conflict" errors on stderr. Each service tried to register GET/PUT handlers at the root path, and the HTTP router threw on duplicates.

Changes

include/glaze/net/http_router.hpp — Allow route replacement (last writer wins) instead of throwing on duplicate method+path registrations. This applies to both direct routes and parameterized radix tree routes, making the router consistent with the map-based storage used by REPE and JSONRPC protocols.

tests/.../http_router_test.cpp — Added tests for route replacement behavior and a service composition test reproducing the exact scenario from the issue (three services on one registry).

docs/ — Updated REST, JSONRPC, and REPE registry docs to document service composition behavior: all member endpoints are registered, the root endpoint reflects the last registered service, and glz::merge is recommended for a combined root view.

@stephenberry stephenberry linked an issue Mar 26, 2026 that may be closed by this pull request
@stephenberry stephenberry merged commit a6f738b into main Mar 26, 2026
48 of 49 checks passed
@stephenberry stephenberry deleted the rest-registry-route-overwriting branch March 26, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Route conflict" error on Service Composition example

1 participant