2017-05-07 03:20:57 +03:00
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Net.Http.Headers;
|
2017-08-23 18:40:40 +03:00
|
|
|
|
using XLabs.Ioc;
|
|
|
|
|
using Bit.App.Abstractions;
|
2017-05-07 03:20:57 +03:00
|
|
|
|
|
|
|
|
|
namespace Bit.App
|
|
|
|
|
{
|
|
|
|
|
public class IdentityHttpClient : HttpClient
|
|
|
|
|
{
|
|
|
|
|
public IdentityHttpClient()
|
|
|
|
|
{
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IdentityHttpClient(HttpMessageHandler handler)
|
|
|
|
|
: base(handler)
|
|
|
|
|
{
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Init()
|
|
|
|
|
{
|
|
|
|
|
DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
2017-08-23 18:40:40 +03:00
|
|
|
|
|
|
|
|
|
var appSettings = Resolver.Resolve<IAppSettingsService>();
|
|
|
|
|
if(!string.IsNullOrWhiteSpace(appSettings.BaseUrl))
|
|
|
|
|
{
|
|
|
|
|
BaseAddress = new Uri($"{appSettings.BaseUrl}/identity");
|
|
|
|
|
}
|
|
|
|
|
else if(!string.IsNullOrWhiteSpace(appSettings.IdentityUrl))
|
|
|
|
|
{
|
|
|
|
|
BaseAddress = new Uri($"{appSettings.IdentityUrl}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//BaseAddress = new Uri("http://169.254.80.80:33656"); // Desktop from VS Android Emulator
|
2017-10-19 04:53:44 +03:00
|
|
|
|
BaseAddress = new Uri("http://192.168.1.3:33656"); // Desktop
|
2017-08-23 18:40:40 +03:00
|
|
|
|
//BaseAddress = new Uri("https://preview-identity.bitwarden.com"); // Preview
|
2017-10-19 04:53:44 +03:00
|
|
|
|
//BaseAddress = new Uri("https://identity.bitwarden.com"); // Production
|
2017-08-23 18:40:40 +03:00
|
|
|
|
}
|
2017-05-07 03:20:57 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|