You definitely want to be creating different routes to handle the multiple return types. Only one IReturn<T>
or IReturnVoid
is expected, or consuming clients wouldn't know how to type the returned data correctly.
[Route("/api/whatever", "GET")]
public class ListWhateverRequest : IReturn<List<Whatever>>
{
public string WhateverId { get; set; }
}
// Action
public List<Whatever> Get(ListWhateverRequest request)
{
...
}
[Route("/api/whatever", "POST,PUT,DELETE")]
public class UpdateWhateverRequest : IReturn<bool>
{
public string WhateverId { get; set; }
}
// Action
public bool Post(UpdateWhateverRequest request)
{
...
}
public bool Put(UpdateWhateverRequest request)
{
...
}
public bool Delete(UpdateWhateverRequest request)
{
...
}
I presume you are returning true
from these methods to show they completed successfully. Do the methods ever return false
when something goes wrong, or is an exception thrown instead? If you are only throwing exception in the method, and never returning false then instead of returning bool
consider using void
methods with IReturnVoid
. The request is therefore successful if it doesn't throw an exception.