To do this in the new API , we implemented the IServiceRunner concept, which separates the execution of your service from its implementation.
To add your own Hooks for services, you just need to override the standard service Runner in AppHost from its default implementation:
public virtual IServiceRunner<TRequest> CreateServiceRunner<TRequest>(ActionContext actionContext) { return new ServiceRunner<TRequest>(this, actionContext);
With your own:
public override IServiceRunner<TRequest> CreateServiceRunner<TRequest>(ActionContext actionContext) { return new MyServiceRunner<TRequest>(this, actionContext);
Where MyServiceRunner is just a custom class that implements custom hooks that interest you, for example:
public class MyServiceRunner<T> : ServiceRunner<T> { public override void OnBeforeExecute(IRequestContext requestContext, TRequest request) {
Also, for smaller error handling options, check out the error handling wiki page .
mythz source share