Skip to content

Instantly share code, notes, and snippets.

View ian-beer's full-sized avatar

Ian Beer ian-beer

View GitHub Profile
@ian-beer
ian-beer / gist:54ff92358b045113c0c1b8e3dd8b718e
Created December 10, 2018 22:11
.Net HttpClient helpers
private static HttpClient _client = new HttpClient();
private static T HttpGet<T>(string url)
{
var response = _client.GetAsync(url).GetAwaiter().GetResult();
if (false == response.IsSuccessStatusCode)
{
var responseContent = response.Content.ReadAsStringAsync();
@ian-beer
ian-beer / FaultRetryUtility.cs
Last active March 12, 2019 17:35
async fault retry utility inspired from Microsoft docs
/*
useage:
var updateResult = await FaultRetryUtility.AsyncFaultRetry(() => _aManager.UpdateSomthing(Id, data), _logger);
will have to figure out your own log interface
*/
using System;
using System.Configuration;
@ian-beer
ian-beer / RestClient.cs
Last active March 26, 2021 10:34
.Net RestClient
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http.Headers;
using Newtonsoft.Json.Linq;
namespace HttpUtils
{
public static class RestClient
{