Skip to content

Commit

Permalink
fix ServiceRunner signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jan 3, 2025
1 parent 9eb8497 commit 0c642e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
8 changes: 4 additions & 4 deletions MyApp/_pages/api-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,20 +797,20 @@ Where `MyServiceRunner<T>` is just a custom class implementing the custom hooks
```csharp
public class MyServiceRunner<T> : ServiceRunner<T>
{
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<object> ExecuteAsync(IRequest req, object serviceInstance, TRequest requestDto) {
public override Task<object> 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<object> HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex) {
public override Task<object> HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex, object instance) {
// Called whenever an exception is thrown in your Services Action
}
}
Expand Down
20 changes: 9 additions & 11 deletions MyApp/_pages/customize-http-responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,20 @@ Where `MyServiceRunner<T>` is just a custom class implementing the custom hooks
```csharp
public class MyServiceRunner<T> : ServiceRunner<T>
{
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<object> 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<object> HandleExceptionAsync(IRequest req, TRequest requestDto, Exception ex, object instance) {
// Called whenever an exception is thrown in your Services Action
}
}
Expand Down
4 changes: 2 additions & 2 deletions MyApp/_pages/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ public class MyServiceRunner<T> : ServiceRunner<T>
public MyServiceRunner(IAppHost appHost, ActionContext actionContext)
: base(appHost, actionContext) {}

public override object HandleException(IRequest request,
T request, Exception ex) {
public override Task<object> HandleExceptionAsync(IRequest req, TRequest requestDto,
Exception ex, object service) {
// Called whenever an exception is thrown in your Services Action
}
}
Expand Down

0 comments on commit 0c642e8

Please sign in to comment.