Technical article
A route that serves a web page: the temporary approval form sample
TempApprovalMockSrv shows how one Camel XML route package can serve a designed approval form, accept JSON submissions, and unload cleanly when the route file is deleted — no frontend build, no database, no restart.
What the sample contains
Four routes in a single XML file form a complete temporary approval loop.
Form page (GET)
An Undertow listener returns a complete HTML page inlined with CDATA, with an explicit text/html;charset=UTF-8 content type.
Submit (POST)
JSON fields are extracted with jsonpath, missing fields return a 400, and a successful submit returns a mock approval id.
View (GET)
Returns fixed mock data for the requested approval id.
Approve (POST)
Validates the APPROVE/REJECT action and returns the approval result with a final status.
Page design without a frontend stack
The page is styled entirely through CSS variables: a gradient brand color, card-based sections with numbered step markers, semantic status badges (amber for PENDING, green for APPROVED, red for REJECTED), and automatic dark mode via prefers-color-scheme.
Interactions use plain fetch and a few lines of vanilla JavaScript. No UI framework and no CDN resources are loaded, so the page works the same in offline and intranet environments, and re-branding only means editing the CSS variables.
Mock boundary and lifecycle
The service has no persistence. Both the page and the API responses state clearly that the data is mocked and disappears with the service.
Deleting the route XML unloads the service and releases its port; putting the file back hot-loads it again. That is exactly the right shape for a temporary demonstration service.
Run it yourself
- Copy example/routes/TempApprovalMockSrv into the runtime lightesb-camel-app/ directory.
- Wait for hot loading, then open http://127.0.0.1:19097/api/temp-approval/form in a browser.
- Submit an approval request, view it, and approve or reject it — watch the status badge and result card change.
- Delete the route XML and confirm the routes unload and the port is released.
When to use this pattern
Temporary forms, approval demos, data collection pages, and POC mock services all fit this pattern. A formal approval workflow that needs persistence and a state machine should connect to H2 storage instead — see the H2 component documentation in the delivery package.