private void OnExecuteRoute(HttpRequest request, HttpResponse response) { var route = ServiceRoute.Parse(request); var module = _modules.FirstOrDefault(m => m.SearchRoute(route)); if (module == null) { response.Error("地址不存在").Send(); return; } var result = module.ExecuteRoute(route, request); if (!result.Success) { response.FromText(result.Message.ToString()).Send(); return; } if (result.GetType() == typeof(JsonSuccess) && result.Result != null) { response.FromJson(result.Result).Send(); } else { response.FromText(result.Result.ToString()).Send(); } }
public override void OnGet(HttpRequest request, HttpResponse response) { ServiceRoute route = ServiceRoute.Parse(request); ServiceModule module = m_modules.FirstOrDefault(m => m.SearchRoute(route)); if (module != null) { var result = module.ExecuteRoute(route); } }
private void OnExecuteRoute(HttpRequest request, HttpResponse response) { var route = ServiceRoute.Parse(request); var module = _modules.FirstOrDefault(m => m.SearchRoute(route)); if (module == null) { response.Error("地址不存在").Send(); return; } var result = module.ExecuteRoute(route, request); if (result is IJsonResult) { response.FromJson(result).Send(); } else if (result is ActionResult actionResult) { response.FromText(actionResult.Data.ToString()).Send(); } }