From 13da69bb6089c13bb74f872ec2dab9d9c0ada78a Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Mon, 23 May 2016 16:49:11 -0400 Subject: [PATCH] lib/popcorn: extract Router::build_route private service Signed-off-by: Alexandre Terrasa --- lib/popcorn/pop_handlers.nit | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/popcorn/pop_handlers.nit b/lib/popcorn/pop_handlers.nit index 2c85e15..2ce4755 100644 --- a/lib/popcorn/pop_handlers.nit +++ b/lib/popcorn/pop_handlers.nit @@ -311,14 +311,7 @@ class Router # # Route paths are matched in registration order. fun use(path: String, handler: Handler) do - var route - if handler isa Router or handler isa StaticHandler then - route = new AppGlobRoute(path) - else if path.has_suffix("*") then - route = new AppGlobRoute(path) - else - route = new AppParamRoute(path) - end + var route = build_route(handler, path) handlers[route] = handler end @@ -329,6 +322,16 @@ class Router if res.sent then break end end + + private fun build_route(handler: Handler, path: String): AppRoute do + if handler isa Router or handler isa StaticHandler then + return new AppGlobRoute(path) + else if path.has_suffix("*") then + return new AppGlobRoute(path) + else + return new AppParamRoute(path) + end + end end # Popcorn application. -- 1.7.9.5