Skip to content

Instantly share code, notes, and snippets.

@dylanberry
Last active May 24, 2019 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanberry/6a5cf9c721e93548eacca391efb1a7d9 to your computer and use it in GitHub Desktop.
Save dylanberry/6a5cf9c721e93548eacca391efb1a7d9 to your computer and use it in GitHub Desktop.
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using VersionCheck.Common;
namespace VersionCheck
{
public class VersionCheckHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
await ProcessRequest(request, cancellationToken);
var response = await base.SendAsync(request, cancellationToken);
return response;
}
protected virtual Task<HttpRequestMessage> ProcessRequest(HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add(HeaderKeys.ClientVersion, Xamarin.Essentials.VersionTracking.CurrentVersion);
return Task.FromResult(request);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment