I am creating an web.api (v1 in c#) for an iOS app. The app is sending gps-date to the app in 1 burst. So we wanted to gzip the data in the app and then process that data.
I created a DelegatingHandler
public class GZipToJsonHandler : DelegatingHandler
{
public GZipToJsonHandler(HttpMessageHandler innerHandler)
{
InnerHandler = innerHandler;
}
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
/* removed unzip code */
/* removed log call */
return base.SendAsync(request, cancellationToken);
}
}
and added a custom route
var handler = new HttpControllerDispatcher(config);
config.Routes.MapHttpRoute(
"WithGZip",
"client/GPSDataWithGZip",
null,
null, new GZipToJsonHandler(handler)
);
When the app calls the route, I can see in the log-files that the handler gets called.
But when it hits base.async
it returns "No HTTP resource found that matches the requested URI"
I've added a lot of logging, but I cannot seem to find why it cannot find the resource it has already hit
in the client controller I have this action
public HttpResponseMessage GPSDataWithGZip([FromBody] GpsRequest model)
{
return SaveGPSData(model);
}
It looks like the InnerHandler couldn't match the current url to a route. after adding default to the route it worked.
defaults: new {controller='client', action='GPSDataWithGZip'}