1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-22 13:35:10 -05:00

icons settings

This commit is contained in:
Kyle Spearrin 2017-10-09 14:02:57 -04:00
parent 164d4e1fb4
commit c52add4051
4 changed files with 25 additions and 4 deletions

View File

@ -4,17 +4,22 @@ using System.Threading.Tasks;
using Bit.Icons.Models; using Bit.Icons.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
namespace Bit.Icons.Controllers namespace Bit.Icons.Controllers
{ {
[Route("")] [Route("")]
public class IconController : Controller public class IconsController : Controller
{ {
private readonly IMemoryCache _memoryCache; private readonly IMemoryCache _memoryCache;
private readonly IconsSettings _iconsSettings;
public IconController(IMemoryCache memoryCache) public IconsController(
IMemoryCache memoryCache,
IOptions<IconsSettings> iconsSettingsOptions)
{ {
_memoryCache = memoryCache; _memoryCache = memoryCache;
_iconsSettings = iconsSettingsOptions.Value;
} }
[HttpGet("")] [HttpGet("")]
@ -57,9 +62,9 @@ namespace Bit.Icons.Controllers
return new FileContentResult(icon.Image, icon.Format); return new FileContentResult(icon.Image, icon.Format);
} }
private static string BuildIconUrl(Uri uri) private string BuildIconUrl(Uri uri)
{ {
return $"https://icons.bitwarden.com/icon?url={uri.Host}&size=16..24..200"; return $"{_iconsSettings.BestIconBaseUrl}/icon?url={uri.Host}&size=16..24..200";
} }
} }
} }

View File

@ -0,0 +1,7 @@
namespace Bit.Icons
{
public class IconsSettings
{
public virtual string BestIconBaseUrl { get; set; }
}
}

View File

@ -17,6 +17,12 @@ namespace Bit.Icons
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Options
services.AddOptions();
// Settings
services.Configure<IconsSettings>(Configuration.GetSection("IconsSettings"));
services.AddMemoryCache(); services.AddMemoryCache();
services.AddMvc(); services.AddMvc();
} }

View File

@ -11,5 +11,8 @@
"Default": "Warning" "Default": "Warning"
} }
} }
},
"iconsSettings": {
"BestIconBaseUrl": "https://icons.better-idea.org"
} }
} }