Example #1
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));
        }
Example #2
0
        public object Get(string id)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            if (reqId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            return(RequestFilteringHelper.ToJsonModel(site, reqId.Path));
        }
Example #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));
        }
Example #4
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            RequestFilteringId reqId = new RequestFilteringId(id);

            Site site = reqId.SiteId == null ? null : SiteHelper.GetSite(reqId.SiteId.Value);

            if (reqId.SiteId != null && site == null)
            {
                Context.Response.StatusCode = (int)HttpStatusCode.NotFound;
                return(null);
            }

            // Check for config_scope
            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);
            RequestFilteringSection section = RequestFilteringHelper.GetRequestFilteringSection(site, reqId.Path, configPath);

            RequestFilteringHelper.UpdateFeatureSettings(model, section);

            ManagementUnit.Current.Commit();

            return(RequestFilteringHelper.ToJsonModel(site, reqId.Path));
        }