fix(API): routing logic should be done after request mw

Routing logic should be done after the execution of request middleware. The execution of request middleware
should be aware of routing logic. A logRequest middleware could not be executed if routing fails, or a mw
can not be executed if a routing fails.