-
Notifications
You must be signed in to change notification settings - Fork 475
Open
Milestone
Description
Currently I'm trying to add per-route delegating handler. but seems there is no proper method in src/Microsoft.AspNet.OData/Extensions/HttpConfigurationExtensions.cs which can support both ODataBatchHandler and HttpMessageHandler as parameters. It is a common case if we want use ODataBatchHandler + HttpMessageHandler
Assemblies affected
*Which assemblies and versions are known to be affected e.g. OData WebApi lib 5.9.0
Additional detail
In order to solve the issue, I have to create my own extension method as below
public static void MapODataServiceRouteWithHandler(
this HttpConfiguration httpConfiguration,
string routeName,
string routePrefix,
IEdmModel model,
List<IODataRoutingConvention> routingConventions,
IODataPathHandler pathHandler,
HttpMessageHandler defaultHandler,
ODataBatchHandler batchHandler)
{
HttpRouteCollection routes = httpConfiguration.Routes;
if (batchHandler != null)
{
batchHandler.ODataRouteName = routeName;
string routeTemplate = string.IsNullOrEmpty(routePrefix) ? ODataRouteConstants.Batch : routePrefix + (object)'/' + ODataRouteConstants.Batch;
routes.MapHttpBatchRoute(routeName + "Batch", routeTemplate, batchHandler);
}
routingConventions.AddRange(ODataRoutingConventions.CreateDefaultWithAttributeRouting(httpConfiguration, model));
httpConfiguration.MapODataServiceRoute(
routeName: routeName,
routePrefix: routePrefix,
model: model,
pathHandler: pathHandler,
routingConventions: routingConventions,
defaultHandler: defaultHandler);
}