Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Created October 9, 2013 09:25
Show Gist options
  • Select an option

  • Save JakeGinnivan/6898623 to your computer and use it in GitHub Desktop.

Select an option

Save JakeGinnivan/6898623 to your computer and use it in GitHub Desktop.
public interface IHttpCall
{
Task<HttpResponseMessage> Execute(HttpClient httpClient);
}
public interface IHttpWithResult<T> : IHttpCall
{
}
public interface IHttpCallExecutor
{
Task Execute(IHttpCall httpCall);
Task<T> Execute<T>(IHttpWithResult<T> httpCallWithResult) where T : class;
}
public class SampleCall : IHttpCall
{
public Task<HttpResponseMessage> Execute(HttpClient httpClient)
{
var requestUri = "/some/relative/path";
return httpClient.PostAsync(requestUri, new StringContent(string.Empty));
}
}
public class SampleCallWithResult : IHttpCallWithResult<string>
{
public Task<HttpResponseMessage> Execute(HttpClient httpClient)
{
var requestUri = "/some/relative/path";
return httpClient.PostAsync(requestUri, new StringContent(string.Empty));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment