is there a way to log the path of a call with gene...
# ktor
c
is there a way to log the path of a call with generic path parameters instead of the actual values sent by the client?
Copy code
POST /images/{id}/likes // desired
POST /images/997/likes
I'm looking to strip the actual id values so that I can consolidate route permutations when calculating usage analytics. It's something I could also do in a separate script or query, but thought it might be easy to do on the ktor server itself.
a
You can write a route-scoped plugin to get access to the
Route
object during the call. Here is an example:
Copy code
routing {
    route("/images/{id}/likes") {
        install(createRouteScopedPlugin("test") {
            val route = this.route
            onCall {
                println("Route: ${route.toString()}")
            }
        })

        post {
            call.respondText { "OK" }
        }
    }
}
👍 1
c
nice... thanks!