switch from middleware pattern to hook system and appengine_config