Reputation: 1479
Is there an easy way to access the Request object from a nested service call?
For example:
// Entry Point
public class ServiceA : Service
{
public AResponse Get(ARequest request)
{
// Request is ok in entry point.
// Now call another service
var srvResp = TryResolve<ServiceB>().Get(new BRequest{ ... });
}
}
// Called through Service A
ServiceB : Service
{
public BResponse Get(BRequest request)
{
// Request is not set here (null).
}
}
Upvotes: 1
Views: 48
Reputation: 21501
You should use ResolveService<T>
method provided by the Service
class to resolve the service. This will make the Request
object available to the service you are resolving.
public class ServiceA : Service
{
public AResponse Get(ARequest request)
{
// Request is ok in entry point.
// Use ResolveService<T> here not TryResolve<T>
var srvResp = ResolveService<ServiceB>().Get(new BRequest{ ... });
}
}
Hope that helps
Upvotes: 3