Default routes have changed to:
/[json/xml/jsv/csv/form]/[requestreply/oneway]/[operation name]
The REST routes (AsyncRestHandler
) and the SOAP handler (AsyncSoapHandler
) are using IHttpAsyncHandler
to process requests.
Created AsyncServiceBase
and AsyncRestServiceBase
to support async/await
.
The refactored ServiceController
now contains two new methods:
ExecuteAsync()
ExecuteOneWay()
The mechanism to find the REST route for a specific request was extracted out in a separate class from ServiceController
: https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack/ServiceHost/RestController.cs.
Sync response binders:
this.ResponseBinders[typeof(ResponseBinderResponse)] = (service, request, response) => ...
Async response binders (only available from IServiceController
):
IServiceController controller = new ServiceController();
controller.AsyncResponseBinders.Add((service, request, response, callback) =>
{
//return IServiceResult and execute callback
//...
});
The Task plugin is using an async response binder to handle Task<>
return types.
See the implementation of Convert()
to see the custom processing for Task<>
(https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack.Plugins.Tasks/TaskSupport.cs).
ServiceStack v4.00 supports the [Route("/path")]
attribute (https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack.Interfaces/ServiceHost/RouteAttribute.cs). [RestService]
is still supported, but was marked as deprecated.
For a route (REST path) allowed Content-Type
s can be set (https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack.Interfaces/ServiceHost/RouteAttribute.cs#L182). If the Content-Type
of the request is not valid according to AllowedContentTypes
, ServiceStack will try to deserialize the request with the first allowed Content-Type
provided.
The default routes use this functionality to limit their Content-Type
, e. g. https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack/ServiceHost/RestController.cs#L36. Look at DefaultRouteTests to see the exact behavior of the default routes.
The attribute also exposes a PreferredContentType
property. not implemented yet
One-way routes can be declared by doing [Route("/path", IsOneWay = true)]
. For a one-way route, void ExecuteOneWay(T request)
of IOneWayService
(https://github.com/ServiceStack/ServiceStack/blob/async/src/ServiceStack.Interfaces/ServiceHost/IOneWayService.cs) is called.
Removed formats from the EndpointAttributes enum. The user can already inspect the Content-Type of the request from IHttpRequest, so there's no need for this extra abstraction.
Additionally EndpointAttributes.LocalSubnet does not exist anymore since the overhead to check if the request is from the local subnet is too big. ServiceStack now uses IHttpRequest.IsLocal to determine if the request is from localhost or external (if a user wants to know if the request is from the local subnet, they should handle this information themselves).
Removed ServiceAttribute and the corresponding tests - this functionality is replaced with a filter attribute.