public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            // Ssl settings cannot be configured at server level
            if (site == null)
            {
                return(NotFound());
            }

            dynamic d = SslSettingsHelper.ToJsonModel(site, path);

            return(LocationChanged(SslSettingsHelper.GetLocation(d.id), d));
        }
Example #2
0
        public override void Start()
        {
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "SslSettings" });

            // Self
            Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", settings => new { href = SslSettingsHelper.GetLocation(settings.id) });

            // Site
            Environment.Hal.ProvideLink(Sites.Defines.Resource.Guid, Defines.Resource.Name, site => {
                var siteId = new SiteId((string)site.id);
                Site s     = SiteHelper.GetSite(siteId.Id);
                var id     = new SslSettingId(siteId.Id, "/", SslSettingsHelper.IsSectionLocal(s, "/"));
                return(new { href = SslSettingsHelper.GetLocation(id.Uuid) });
            });

            // Application
            Environment.Hal.ProvideLink(Applications.Defines.Resource.Guid, Defines.Resource.Name, app => {
                var appId = new ApplicationId((string)app.id);
                Site s    = SiteHelper.GetSite(appId.SiteId);
                var id    = new SslSettingId(appId.SiteId, appId.Path, SslSettingsHelper.IsSectionLocal(s, appId.Path));
                return(new { href = SslSettingsHelper.GetLocation(id.Uuid) });
            });
        }