aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/BrandingService.cs
blob: f5845f4e03cf2fb5b78a89dc194eeb76cf08615c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Branding;
using MediaBrowser.Model.Services;

namespace MediaBrowser.Api
{
    [Route("/Branding/Configuration", "GET", Summary = "Gets branding configuration")]
    public class GetBrandingOptions : IReturn<BrandingOptions>
    {
    }

    [Route("/Branding/Css", "GET", Summary = "Gets custom css")]
    [Route("/Branding/Css.css", "GET", Summary = "Gets custom css")]
    public class GetBrandingCss
    {
    }

    public class BrandingService : BaseApiService
    {
        private readonly IConfigurationManager _config;

        public BrandingService(IConfigurationManager config)
        {
            _config = config;
        }

        public object Get(GetBrandingOptions request)
        {
            return _config.GetConfiguration<BrandingOptions>("branding");
        }

        public object Get(GetBrandingCss request)
        {
            var result = _config.GetConfiguration<BrandingOptions>("branding");

            // When null this throws a 405 error under Mono OSX, so default to empty string
            return ResultFactory.GetResult(Request, result.CustomCss ?? string.Empty, "text/css");
        }
    }
}