Reputation: 36
When trying to execute a POST request Delete(SourceInfo sourceInfo)
is executed instead of Post(SourceInfo sourceInfo)
, if I remove Delete(SourceInfo sourceInfo)
then Put(SourceInfo sourceInfo)
is executed when executing a POST request. I'm pretty sure I'm doing something wrong, but I'm not able to figure out what it is.
Routes are reqistred using the IPlugin
interface.
public void Register(IAppHost appHost)
{
appHost.Routes.Add<SourceInfo>("/sources", "GET,POST,PUT");
appHost.Routes.Add<SourceInfo>("/sources/{Name}", "GET,DELETE");
}
The service looks like this
public class SourceService : ServiceStack.ServiceInterface.Service
{
public SourceInfoResponse Get(SourceInfo sourceInfo)
{ ... }
public bool Post(SourceInfo source)
{ ... }
public bool Put(SourceInfo source)
{ ... }
public bool Delete(SourceInfo source)
{ ... }
}
I looked at the routing description for the new api design here: https://github.com/ServiceStack/ServiceStack/wiki/New-API, but is does not look like this applies in this case.
Upvotes: 1
Views: 111
Reputation: 36
So I figured it out, it turns out that returning bool
does not work. When I changed the return to type to object
it worked right away.
like this
public class SourceService : ServiceStack.ServiceInterface.Service
{
public SourceInfoResponse Get(SourceInfo sourceInfo)
{ ... }
public object Post(SourceInfo source)
{ ... }
public object Put(SourceInfo source)
{ ... }
public object Delete(SourceInfo source)
{ ... }
}
It also works to return a custom class.
Upvotes: 1