mirror of
https://github.com/bitwarden/server.git
synced 2025-01-26 22:31:30 +01:00
icons settings
This commit is contained in:
parent
164d4e1fb4
commit
c52add4051
@ -4,17 +4,22 @@ using System.Threading.Tasks;
|
||||
using Bit.Icons.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Bit.Icons.Controllers
|
||||
{
|
||||
[Route("")]
|
||||
public class IconController : Controller
|
||||
public class IconsController : Controller
|
||||
{
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private readonly IconsSettings _iconsSettings;
|
||||
|
||||
public IconController(IMemoryCache memoryCache)
|
||||
public IconsController(
|
||||
IMemoryCache memoryCache,
|
||||
IOptions<IconsSettings> iconsSettingsOptions)
|
||||
{
|
||||
_memoryCache = memoryCache;
|
||||
_iconsSettings = iconsSettingsOptions.Value;
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
@ -57,9 +62,9 @@ namespace Bit.Icons.Controllers
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
7
src/Icons/IconsSettings.cs
Normal file
7
src/Icons/IconsSettings.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Bit.Icons
|
||||
{
|
||||
public class IconsSettings
|
||||
{
|
||||
public virtual string BestIconBaseUrl { get; set; }
|
||||
}
|
||||
}
|
@ -17,6 +17,12 @@ namespace Bit.Icons
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Options
|
||||
services.AddOptions();
|
||||
|
||||
// Settings
|
||||
services.Configure<IconsSettings>(Configuration.GetSection("IconsSettings"));
|
||||
|
||||
services.AddMemoryCache();
|
||||
services.AddMvc();
|
||||
}
|
||||
|
@ -11,5 +11,8 @@
|
||||
"Default": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"iconsSettings": {
|
||||
"BestIconBaseUrl": "https://icons.better-idea.org"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user