Dmitry Kandalov
03/01/2024, 11:24 AMroutes()
which chooses the first matching handler? Or is it the wrong thing to do anyway?
For the context I’m profiling a simple http4k app (with get/set endpoints) and can see that OrRouter
takes about 5% of time. Wondering if there is an easy way to make it ~0% 😅dave
03/01/2024, 11:26 AMdave
03/01/2024, 11:29 AMdave
03/01/2024, 11:29 AMdave
03/01/2024, 11:29 AMoverride fun match(request: Request): RouterMatch {
val matches = list.map { next -> next.match(request) }
val result = matches.minOrNull() ?: Unmatched(description)
return result.aggregatedBy(description, matches)
}
dave
03/01/2024, 11:30 AMDmitry Kandalov
03/01/2024, 11:31 AMoverride fun match(request: Request) =
list.asSequence()
.map { next -> next.match(request) }
.filterIsInstance<MatchingHandler>()
.firstOrNull() ?: Unmatched(description)
dave
03/01/2024, 11:32 AMJames Richardson
03/01/2024, 2:36 PMDmitry Kandalov
03/12/2024, 5:21 PMFirstMatchRouter
means I need to copy-paste RouterBasedHttpHandler
because it’s internal in http4k-core.