Rewrite Api server handler