private void ConfigureStaticContent()
        {
            // Provide mvc with route
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "staticcontent" });

            // Register self hypermedia
            Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", sc => new { href = StaticContentHelper.GetLocation(sc.id) });

            // Web Server
            Environment.Hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => {
                var id = GetStaticContentId(null, null);
                return(new { href = StaticContentHelper.GetLocation(id.Uuid) });
            });

            // 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     = GetStaticContentId(s, "/");
                return(new { href = StaticContentHelper.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    = GetStaticContentId(s, appId.Path);
                return(new { href = StaticContentHelper.GetLocation(id.Uuid) });
            });
        }
Example #2
0
        public async Task <object> Post()
        {
            if (StaticContentHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(StaticContentHelper.DISPLAY_NAME);
            }

            await StaticContentHelper.SetFeatureEnabled(true);

            dynamic settings = StaticContentHelper.ToJsonModel(null, null);

            return(Created(StaticContentHelper.GetLocation(settings.id), settings));
        }
Example #3
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

            if (path == null)
            {
                return(NotFound());
            }

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

            return(LocationChanged(StaticContentHelper.GetLocation(d.id), d));
        }