Is there any way to reroute requests based on properties of the request DTO that aren’t part of the url?
For example, given this request DTO:
[Route("/mything/{Id}", "PUT")]
public class UpdateMyThing : IReturn<ThingResponse> {
public Guid Id { get; set; }
public ThingType Type { get; set; }
}
Is there any way I can define two different services (with different RequestFilterAttributes
) to handle this request depending on the value of the Type
property? Something like the following, but where the RequestFilterAttributes
are actually invoked (in this example they are not):
public ThingResponse Put(UpdateMyThing request) {
if(request.Type == ThingType.Big)
return UpdateBigThing(request);
else
return UpdateSmallThing(request);
}
[CheckPermission(Permissions.Big)]
private ThingResponse UpdateBigThing(UpdateMyThing request) { ... }
[CheckPermission(Permissions.Small)]
private ThingResponse UpdateSmallThing(UpdateMyThing request) { ... }
I did try playing around with HostContext.ServiceController.ExecuteMessage
a bit, but couldn’t really wrap my head around the best way to use it (it gives me an IHttpResult
which I think means my Put
service could no longer return a ThingResponse
object).
Worst-case I can move my permission check into the service itself instead of an attribute, but I’d prefer not to (for clarity and consistency purposes) if possible.