1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-26 22:31:30 +01:00

allow custom size to be passed in

This commit is contained in:
Kyle Spearrin 2017-10-09 14:25:59 -04:00
parent 4d7bd85490
commit c88f4064f1

View File

@ -28,7 +28,7 @@ namespace Bit.Icons.Controllers
}
[HttpGet("")]
public async Task<IActionResult> Get([FromQuery] string domain)
public async Task<IActionResult> Get([FromQuery]string domain, [FromQuery]string size = "16..24..200")
{
if(!domain.StartsWith("http://") || !domain.StartsWith("https://"))
{
@ -41,11 +41,12 @@ namespace Bit.Icons.Controllers
}
var mappedDomain = _domainMappingService.MapDomain(uri.Host);
var icon = await _memoryCache.GetOrCreateAsync(mappedDomain, async entry =>
var cacheKey = $"{mappedDomain}_{size}";
var icon = await _memoryCache.GetOrCreateAsync(cacheKey, async entry =>
{
entry.AbsoluteExpiration = DateTime.UtcNow.AddHours(_iconsSettings.CacheHours);
var iconUrl = $"{_iconsSettings.BestIconBaseUrl}/icon?url={mappedDomain}&size=16..24..200";
var iconUrl = $"{_iconsSettings.BestIconBaseUrl}/icon?url={mappedDomain}&size={size}";
var response = await _httpClient.GetAsync(iconUrl);
if(!response.IsSuccessStatusCode)
{