Reputation: 4648
I have a Spring Integration DSL Flow and I'm trying to access the HTTP request path. Possible paths look something like this
/import: imports everything
/import/case1: imports only part A
/import/case2: imports only part B
/import/case2/{filename}: imports only a single file from part B
My flow looks something like this
return IntegrationFlow
.from(Http.inboundChannelAdapter(IMPORT_BASE_PATH + "/**")
.requestMapping(mapping -> mapping.methods(POST)))
Upvotes: 0
Views: 29
Reputation: 4648
Ok, I found the answer relatively easily myself:
return IntegrationFlow
.from(Http.inboundChannelAdapter(IMPORT_BASE_PATH + "/**")
.payloadExpression("#this.url"))
with this, the resulting Message will have the full URL in both of these places
the header.http_requestURL is set automatically.
To get just the path as a string:
return IntegrationFlow
.from(Http.inboundChannelAdapter(IMPORT_BASE_PATH + "/**")
.payloadExpression("#this.url.path"))
EDIT:
Thanks to @artem-bilan's comment, I was able to improve my solution considerably:
return IntegrationFlow
.from(Http.inboundChannelAdapter("/import", "/import/case1", "/import/case2", "/import/case2/{filename}")
.requestMapping(mapping -> mapping.methods(POST))
.headerExpression(SINGLE_MB_TILE_FILENAME, "#pathVariables != null ? #pathVariables.fileName : null")
.payloadExpression("#this.url.path"))
Upvotes: 1