my Akka HTTP application reverse-proxies some requests to an internal HTTP system:
pathPrefix("/api/") {
(path("some-upload-endpoint") & post) {
withSizeLimit(10 * 1024 * 1024) {
reverseProxyToBackend(rc)
}
} ~ reverseProxyToBackend(rc)
}
reverseProxyToBackend is a custom directive that takes the incoming requests, adds some headers and forwards it to the backend system, based on the remaining unmatched path. IOW, /api/foobar becomes backend.example.com/foobar.
For a certain path some-upload-endpoint however I need to increase the default size limit of the frontend, as we expect larger requests to this endpoint.
Unfortunately, path("some-upload-endpoint") consumes the remaining path, so with the above code reverseProxyToBackend would forward to backend.example.com rather than backend.example.com/some-upload-endpoint, which is not what I want.
How can I match a path in Akka HTTP, but not consume it? In other words, what directives can I use to keep the unmatched path untouched by a path matcher? And if there's no such directive, how can I restore the unmatched path?