Extract common middleware into common namespace.