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

orangy

06/08/2019, 4:21 PM
Yes, do a safe cast
call as? RoutingApplicationCall
. If it’s not null, you’re in a route handler (or interceptor) and you can get route from there. However, you need to place interceptor inside
routing
for this to work
🙏 1
m

mp

06/08/2019, 4:43 PM
like this?
Copy code
install(Routing) {
            install(NewRelic)
That doesn’t seem to be sufficient —
call
is
io.ktor.server.netty.http1.NettyHttp1ApplicationCall
. Is this because I’m intercepting at
ApplicationCallPipeline.Monitoring
?
Monitoring
seems like the right thing for new relic, but maybe it has to be later?
Or is this what I’m supposed to do?
Copy code
install(Routing) {
            route("/") {
                intercept(ApplicationCallPipeline.Monitoring) {
                    setUpNewRelic()
                }
where setUpNewRelic is basically the guts of what was the NewRelic feature
Or, making it an extension function on
Route
, can do this:
Copy code
install(Routing) {
            route("/") {
                setUpNewRelic()
I do get
RoutingApplicationCall
that way, so that’s progress. Is that the best I can do? Would it make sense to provide a application Feature at all at this point? (Does anyone use ktor without routing?)
10 Views