Refined router/middleware code tpl