CAMEL-24625: camel-platform-http: add stripUriPrefix option for path-based reverse proxies - #26114
CAMEL-24625: camel-platform-http: add stripUriPrefix option for path-based reverse proxies#26114Croway wants to merge 4 commits into
Conversation
…-based reverse proxies
platform-http is the only HTTP consumer (unlike camel-servlet, camel-jetty,
camel-netty-http and camel-undertow) that does not make CamelHttpPath
relative to the consumer's own registered path, so combining it with the
http producer's bridgeEndpoint option to build a path-based reverse proxy
forwards the full raw request path instead of the path relative to the
consumer.
Add a new consumer option, stripUriPrefix (default false), and a shared
HttpHelper.stripUriPrefix(requestPath, consumerPath) helper in
camel-http-base that other HTTP consumers could reuse. The helper is a
defensive pure function: it only strips a full, boundary-respecting match
of the consumer path (REST-DSL {name} placeholders included) and otherwise
returns the request path unchanged - in particular a consumer path of "/"
(the platform-http:proxy pseudo-path) is always a no-op, so the existing
platform-http:proxy forward-proxy mode is unaffected.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE
Apply HttpHelper.stripUriPrefix to CamelHttpPath in VertxPlatformHttpConsumer.populateCamelMessage when the new consumer option is enabled, using the endpoint's own registered path as the consumer path. This is the single place headers are (re)populated for a request that reaches the route - the OAuth security handler path resets the message and lets processHttpRequest/populateCamelMessage repopulate headers afterwards, so no separate handling is needed there. CamelHttpUri/CamelHttpUrl are untouched, only CamelHttpPath is rewritten. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE
… reverse proxy Add a short section next to the existing reverse-proxy documentation showing the stripUriPrefix + bridgeEndpoint combination, with a before/after CamelHttpPath example and a cross-reference clarifying this is distinct from the platform-http:proxy Host-header forward proxy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
431386b to
4c22753
Compare
✅ Generated files have been updatedA regen commit was automatically pushed to this branch. CI will re-run shortly. |
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 80 tested, 25 compile-only — current: 78 all testedMaveniverse Scalpel detected 105 affected modules (current approach: 78).
|
Problem
platform-httpis the one HTTP consumer that does not makeCamelHttpPathrelative to its own registered path -camel-servlet,camel-jetty,camel-netty-httpandcamel-undertowall strip their registered consumer path already. This means combiningplatform-httpwith thecamel-httpproducer'sbridgeEndpoint=trueto build a zero-code, path-based reverse proxy doesn't work: the full raw request path is forwarded instead of the path relative to the consumer, forcing route authors to manually strip the prefix withsetHeader+ a Simple/OGNLsubstring()expression.Change
Adds a new consumer option
stripUriPrefix(defaultfalse) onplatform-http:HttpHelper.stripUriPrefix(requestPath, consumerPath)incamel-http-base, usable by other HTTP consumers in the future.stripUriPrefixconsumer option onPlatformHttpEndpoint(engine-agnostic).camel-platform-http-vertx); the Spring Boot engine is not wired in this PR - it lives in the separateapache/camel-spring-bootrepo and gets its own follow-up PR (already in progress) once this PR provides the option to build against.CamelHttpUri/CamelHttpUrlare left untouched - onlyCamelHttpPathis rewritten.false), and the existingplatform-http:proxyforward-proxy mode (CAMEL-24455) is provably unaffected: its consumer path is"/", and the helper treats a consumer path of"/"as "nothing to strip".platform-http-component.adoc.JIRA: CAMEL-24625
Opening as a draft pending review from the author (a Camel committer) before it's marked ready for review.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE