https://kotlinlang.org logo
#ktor
Title
# ktor
c

Carlos Fau

05/20/2020, 1:13 PM
Hi. I wrote an Interceptor to obtain the userId and session Id to be pushed into a ContextElement to be able to get those value in other parts of the app without the need to pass them as parameters all through the business logic. The path is like "/api/users/{userId}/rest-of-path" and the code is similar to this:
Copy code
pipeline.intercept(ApplicationCallPipeline.Features) {
                call.parameters["userId"] --> null
                proceed()
            }
The problem is that
call.parameters["userId"]
is always null. I guess I'm doing something wrong. Any help?
I also tried `call.request.parameters["userId"] with same result
Reading more I found that Routing is just another interceptor, so, intercepting before it is useless to get routing data. I replaced a Feature with a route interceptor and solved the problem.
7 Views