예제 #1
0
        public object Get()
        {
            RewriteHelper.ResolveRewrite(Context, out Site site, out string path);

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

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

            return(LocationChanged(ServerVariablesHelper.GetLocation(d.id), d));
        }
예제 #2
0
        public object Get(string id)
        {
            var serverVariablesId = new RewriteId(id);

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

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

            return(ServerVariablesHelper.ToJsonModel(site, serverVariablesId.Path));
        }
예제 #3
0
        public object Patch(string id, [FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }

            RewriteId serverVariablesId = new RewriteId(id);

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

            if (serverVariablesId.SiteId != null && site == null)
            {
                return(NotFound());
            }

            string configPath = model == null ? null : ManagementUnit.ResolveConfigScope(model);

            ServerVariablesHelper.UpdateFeatureSettings(model, site, serverVariablesId.Path, configPath);

            ManagementUnit.Current.Commit();

            return(ServerVariablesHelper.ToJsonModel(site, serverVariablesId.Path));
        }