Skip to content

CAMEL-24625: camel-platform-http: add stripUriPrefix option for path-based reverse proxies - #26114

Merged
Croway merged 5 commits into
apache:mainfrom
Croway:platform-http-strip-uri-prefix
Sep 7, 2026
Merged

CAMEL-24625: camel-platform-http: add stripUriPrefix option for path-based reverse proxies#26114
Croway merged 5 commits into
apache:mainfrom
Croway:platform-http-strip-uri-prefix

Conversation

@Croway

@Croway Croway commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Problem

platform-http is the one HTTP consumer that does not make CamelHttpPath relative to its own registered path - camel-servlet, camel-jetty, camel-netty-http and camel-undertow all strip their registered consumer path already. This means combining platform-http with the camel-http producer's bridgeEndpoint=true to 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 with setHeader + a Simple/OGNL substring() expression.

Change

Adds a new consumer option stripUriPrefix (default false) on platform-http:

from("platform-http:/reverse-proxy?matchOnUriPrefix=true&stripUriPrefix=true")
    .to("http://backend?bridgeEndpoint=true")   // /reverse-proxy/get -> http://backend/get
  • New shared, defensive pure function HttpHelper.stripUriPrefix(requestPath, consumerPath) in camel-http-base, usable by other HTTP consumers in the future.
  • New stripUriPrefix consumer option on PlatformHttpEndpoint (engine-agnostic).
  • Wired up in the Vert.x engine (camel-platform-http-vertx); the Spring Boot engine is not wired in this PR - it lives in the separate apache/camel-spring-boot repo and gets its own follow-up PR (already in progress) once this PR provides the option to build against.
  • CamelHttpUri/CamelHttpUrl are left untouched - only CamelHttpPath is rewritten.
  • Default is unchanged (false), and the existing platform-http:proxy forward-proxy mode (CAMEL-24455) is provably unaffected: its consumer path is "/", and the helper treats a consumer path of "/" as "nothing to strip".
  • Docs added to platform-http-component.adoc.

JIRA: CAMEL-24625

@Croway
Croway marked this pull request as ready for review September 4, 2026 08:48
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@Croway
Croway force-pushed the platform-http-strip-uri-prefix branch from 431386b to 4c22753 Compare September 4, 2026 08:49
@Croway Croway changed the title camel-platform-http: add stripUriPrefix option for path-based reverse proxies CAMEL-24625: camel-platform-http: add stripUriPrefix option for path-based reverse proxies Sep 4, 2026
@Croway
Croway marked this pull request as draft September 4, 2026 08:51
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

✅ Generated files have been updated

A regen commit was automatically pushed to this branch. CI will re-run shortly.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-http-base
  • components/camel-platform-http-vertx
  • components/camel-platform-http
  • dsl/camel-endpointdsl

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.


🔬 Scalpel shadow comparison — Scalpel: 80 tested, 25 compile-only — current: 78 all tested

Maveniverse Scalpel detected 105 affected modules (current approach: 78).

⚠️ Modules only in Scalpel (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 80 modules (5 direct + 75 downstream), skip tests for 25 (generated code, meta-modules)

Modules Scalpel would test (80)
  • camel-a2a
  • camel-ai-observability
  • camel-as2
  • camel-atmosphere-websocket
  • camel-catalog
  • camel-clickup
  • camel-consul
  • camel-cxf-common
  • camel-cxf-rest
  • camel-cxf-soap
  • camel-cxf-spring-common
  • camel-cxf-spring-rest
  • camel-cxf-spring-soap
  • camel-cxf-spring-transport
  • camel-cxf-transport
  • camel-endpointdsl
  • camel-graphql
  • camel-http
  • camel-http-base
  • camel-http-common
  • camel-java-joor-dsl
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jetty
  • camel-jetty-common
  • camel-jsonpath
  • camel-kamelet
  • camel-knative-http
  • camel-kubernetes
  • camel-langchain4j-agent
  • camel-langchain4j-chat
  • camel-langchain4j-embeddings
  • camel-langchain4j-embeddingstore
  • camel-launcher-container
  • camel-lra
  • camel-mcp-server
  • camel-micrometer-observability
  • camel-micrometer-prometheus
  • camel-netty-http
  • camel-oauth
  • camel-observability-services
  • camel-openai
  • camel-openapi-validator
  • camel-opentelemetry
  • camel-opentelemetry2
  • camel-platform-http
  • camel-platform-http-jolokia
  • camel-platform-http-main
  • camel-platform-http-vertx
  • camel-quickfix
  • camel-rest-openapi
  • camel-rest-postman
  • camel-restdsl-openapi-plugin
  • camel-sap-netweaver
  • camel-servlet
  • camel-slack
  • camel-soap
  • camel-spring-ai-chat
  • camel-spring-rabbitmq
  • camel-state-store
  • camel-telegram
  • camel-telemetry
  • camel-telemetry-dev
  • camel-test-main-junit5
  • camel-test-main-junit6
  • camel-undertow
  • camel-undertow-spring-security
  • camel-vertx-http
  • camel-webhook
  • camel-whatsapp
  • camel-xml-io-dsl
  • camel-xml-jaxb-dsl
  • camel-xml-jaxb-dsl-test-definition
  • camel-xml-jaxb-dsl-test-spring
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • camel-zookeeper
Modules with tests skipped (25)
  • apache-camel
  • camel-allcomponents
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

Build reactor — dependencies compiled but only changed modules were tested (5 modules)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Endpoint DSL
  • Camel :: HTTP :: Base
  • Camel :: Platform HTTP
  • Camel :: Platform HTTP :: Vert.x

⚙️ View full build and test results

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this well-scoped PR, Federico! The problem is real and the approach is solid — a pure helper in camel-http-base, an opt-in boolean with false default (no behaviour change for existing routes), thorough unit tests for the helper, and a live integration test for the key reverse-proxy scenario. A couple of small things to consider before marking it ready for review:

1. camel-http-base dependency in camel-platform-http-vertx may be redundant (see inline comment)

2. Case-insensitive segment matching may be dead code in practice (see inline comment)

Questions

  • No upgrade-guide entry is needed for a new opt-in option with default=false — confirming this is intentionally omitted.
  • The integration test doesn't cover {placeholder} consumer paths in the live Vert.x scenario (only the pure-function unit test does). Is that coverage considered sufficient?
  • stripUriPrefix=true without matchOnUriPrefix=true: the docs and tests always combine the two. A brief note or test covering the exact-match case (e.g. GET /reverse-proxy → backend receives /) would remove any ambiguity.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying. This review does not replace CodeRabbit, Sourcery, SonarCloud, or similar tools.

Comment thread components/camel-platform-http-vertx/pom.xml
Croway and others added 5 commits September 7, 2026 17:21
…-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
…match docs/test

Address review feedback: match literal path segments case-sensitively (the
Vert.x router only ever routes case-exact prefixes, so this aligns the helper
with reachable behaviour and HTTP path semantics), drop the two unit cases
that asserted unreachable case-insensitive matching, verify exact-match
stripping in the live Vert.x test without matchOnUriPrefix, and document that
matchOnUriPrefix is not a prerequisite for stripUriPrefix.

Co-authored-by: Claude Code <noreply@anthropic.com>
@davsclaus
davsclaus force-pushed the platform-http-strip-uri-prefix branch from c98b120 to 3de5b67 Compare September 7, 2026 15:21

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after the latest commits. This addresses the previous findings — summary below.

Previous findings — status:

  1. equalsIgnoreCase dead code — Addressed. The helper now uses plain equals() for segment matching, correctly reflecting actual case-sensitive router behaviour.

  2. ⚠️ Redundant camel-http-base dependency in camel-platform-http-vertx/pom.xml — Still present (see inline comment). camel-platform-http already pulls in camel-http-base transitively; the explicit declaration remains unnecessary.

  3. Upgrade guide — No entry needed for a new opt-in false-default option. Correct.

  4. Exact-match case coveragestripUriPrefixOnAnExactMatchLeavesTheRootPath integration test added. Question answered.

  5. matchOnUriPrefix independence — Docs now explicitly state "matchOnUriPrefix is not required for stripUriPrefix." Good.

Static analysis: ast-grep — no findings. semgrep — 2 findings (cookie-missing-httponly, cookie-missing-secure-flag) at VertxPlatformHttpConsumer.java:598, pre-existing in main, not introduced by this PR.

New code quality: The helper logic, unit-test suite, Vert.x integration test, and endpoint wiring are all solid. No new issues beyond the residual nit below.


This review was generated by an AI agent, Hermès, on behalf of @gnodet.

</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http-base</artifactId>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Nit (unaddressed from previous review): This explicit camel-http-base dependency is redundant. camel-platform-http already depends on camel-http-base, so camel-platform-http-vertx gets it transitively via its existing camel-platform-http dependency. Camel's convention avoids redundant explicit deps. Consider removing this <dependency> block.

@Croway
Croway merged commit bda1be5 into apache:main Sep 7, 2026
6 checks passed
Croway added a commit to apache/camel-spring-boot that referenced this pull request Sep 9, 2026
…sumer option

The platform-http consumer option stripUriPrefix (added to PlatformHttpEndpoint
in apache/camel via CAMEL-24625 / apache/camel#26114) was a no-op on the Spring
Boot (servlet) platform-http engine: nothing stripped the registered consumer
path from CamelHttpPath. Wire it up in SpringBootPlatformHttpConsumer, mirroring
the Vert.x engine, so that combined with the http producer's bridgeEndpoint
option a platform-http route becomes a path-based reverse proxy:

    from("platform-http:/reverse-proxy?matchOnUriPrefix=true&stripUriPrefix=true")
        .to("http://backend?bridgeEndpoint=true")   // /reverse-proxy/get -> http://backend/get

Only CamelHttpPath is rewritten; CamelHttpUri/CamelHttpUrl are left untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants