Refactor servlet logic to -> ApiResult