mirror of
https://github.com/bitwarden/server.git
synced 2025-04-21 04:55:08 -05:00
allow custom size to be passed in
This commit is contained in:
parent
4d7bd85490
commit
c88f4064f1
@ -28,7 +28,7 @@ namespace Bit.Icons.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("")]
|
[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://"))
|
if(!domain.StartsWith("http://") || !domain.StartsWith("https://"))
|
||||||
{
|
{
|
||||||
@ -41,11 +41,12 @@ namespace Bit.Icons.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mappedDomain = _domainMappingService.MapDomain(uri.Host);
|
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);
|
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);
|
var response = await _httpClient.GetAsync(iconUrl);
|
||||||
if(!response.IsSuccessStatusCode)
|
if(!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user