If I have a routing setup and I cant figure out wh...
# ktor
s
If I have a routing setup and I cant figure out why something doesnt match.. what is the easiest way to debug it ?
o
For now only to debug the routing matching procedure… We need to think how to make it possible without such complexity. Any ideas?
s
Maybe. I think an api could be to put a
var debug: Boolean
on Route. A debugging strategy would then consist of enabling it on the most specific Route handler and gradually expand out manually by edit, compile, retry until the fault is located. Nested Route matchers inherit this debug flag. Debug enabled routes then output why they either match (or maybe be silent in this case) or do not match (maybe something like Hamcrest but could be overkill) to the logger.
o
That’s a lot of edit/compile/retry… I would may be record a single (complex) object for a routing resolution trace and have a
trace
function on Routing that receives a lambda to do whatever you want with the trace:
Copy code
routing {
   trace { trace: RoutingResolutionTrace -> 
      println(trace)
   }
   …
}
When routing completes and before it executes selected handler, it would call
trace
function (no trace collection if trace function is not installed). You can print a trace, or simply set breakpoint and inspect it in the debugger.
s
Looks good