private void ConfigureRequestFiltering()
        {
            // MVC routing
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "requestfiltering" });

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


            // Web Server
            Environment.Hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => {
                var id = GetRequestFilteringId(null, null);
                return(new { href = RequestFilteringHelper.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     = GetRequestFilteringId(s, "/");
                return(new { href = RequestFilteringHelper.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    = GetRequestFilteringId(s, appId.Path);
                return(new { href = RequestFilteringHelper.GetLocation(id.Uuid) });
            });
        }
Пример #2
0
        public async Task <object> Post()
        {
            if (RequestFilteringHelper.IsFeatureEnabled())
            {
                throw new AlreadyExistsException(RequestFilteringHelper.DISPLAY_NAME);
            }

            await RequestFilteringHelper.SetFeatureEnabled(true);

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

            return(Created(RequestFilteringHelper.GetLocation(settings.id), settings));
        }
Пример #3
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

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

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

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