我想在播放框架过滤器(2.1.2)中按类型跟踪调用。
object WhichEndpointCallMetricsFilter extends Filter {
def apply(next: RequestHeader => Result)(rh: RequestHeader) = {
rh.path match {
case x if x startsWith "/devices" => Metrics.registry.meter(MetricRegistry.name("http.requests.devices." + rh.method)).mark()
case x if x startsWith "/messages" => Metrics.registry.meter(MetricRegistry.name("http.requests.ping." + rh.method)).mark()
case _ => Metrics.registry.meter(MetricRegistry.name("http.requests.UNKNOWN." + rh.method)).mark()
}
next(rh)
}
}
我根本不喜欢的是我正在复制已经在“路由”文件中定义的路径(如“/devices”)。有没有办法在过滤器中查找目标控制器类?
我确信有一个类似游戏的助手,例如:
Routes.lookupControllerClass(request):Controller