From 0c642e8840b9f9f1ed0757a6e4fddf0b10ac844e Mon Sep 17 00:00:00 2001 From: Demis Bellot Date: Fri, 3 Jan 2025 22:10:03 +0800 Subject: [PATCH] fix ServiceRunner signatures --- MyApp/_pages/api-design.md | 8 ++++---- MyApp/_pages/customize-http-responses.md | 20 +++++++++----------- MyApp/_pages/error-handling.md | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/MyApp/_pages/api-design.md b/MyApp/_pages/api-design.md index 3c6071acbe..a148cf1ace 100644 --- a/MyApp/_pages/api-design.md +++ b/MyApp/_pages/api-design.md @@ -797,20 +797,20 @@ Where `MyServiceRunner` is just a custom class implementing the custom hooks ```csharp public class MyServiceRunner : ServiceRunner { - public override void OnBeforeExecute(IRequest req, TRequest requestDto) { + public override OnBeforeExecute(IRequest req, TRequest request, object service) { // Called just before any Action is executed } - public override Task ExecuteAsync(IRequest req, object serviceInstance, TRequest requestDto) { + public override Task ExecuteAsync(IRequest req, object instance, TRequest requestDto) { // Called to execute the Service instance with the requestDto return base.ExecuteAsync(req, serviceInstance, requestDto); } - public override object OnAfterExecute(IRequest req, object response) { + public override object OnAfterExecute(IRequest req, object response, object service) { // Called just after any Action is executed, you can modify the response returned here as well } - public override Task HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex) { + public override Task HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex, object instance) { // Called whenever an exception is thrown in your Services Action } } diff --git a/MyApp/_pages/customize-http-responses.md b/MyApp/_pages/customize-http-responses.md index a2c90bd0aa..849d3d2948 100644 --- a/MyApp/_pages/customize-http-responses.md +++ b/MyApp/_pages/customize-http-responses.md @@ -287,22 +287,20 @@ Where `MyServiceRunner` is just a custom class implementing the custom hooks ```csharp public class MyServiceRunner : ServiceRunner { - public override void OnBeforeExecute( - IRequest requestContext, TRequest request) - { + public override OnBeforeExecute(IRequest req, TRequest request, object service) { // Called just before any Action is executed } - public override object OnAfterExecute( - IRequest requestContext, object response) - { - // Called just after any Action is executed. - // You can modify the response returned here as well + public override Task ExecuteAsync(IRequest req, object instance, TRequest requestDto) { + // Called to execute the Service instance with the requestDto + return base.ExecuteAsync(req, serviceInstance, requestDto); } - public override object HandleException( - IRequest requestContext, TRequest request, Exception ex) - { + public override object OnAfterExecute(IRequest req, object response, object service) { + // Called just after any Action is executed, you can modify the response returned here as well + } + + public override Task HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex, object instance) { // Called whenever an exception is thrown in your Services Action } } diff --git a/MyApp/_pages/error-handling.md b/MyApp/_pages/error-handling.md index 6e6b970d26..15fa8a17f6 100644 --- a/MyApp/_pages/error-handling.md +++ b/MyApp/_pages/error-handling.md @@ -405,8 +405,8 @@ public class MyServiceRunner : ServiceRunner public MyServiceRunner(IAppHost appHost, ActionContext actionContext) : base(appHost, actionContext) {} - public override object HandleException(IRequest request, - T request, Exception ex) { + public override Task HandleExceptionAsync(IRequest req, TRequest requestDto, + Exception ex, object service) { // Called whenever an exception is thrown in your Services Action } }