public object Get()
        {
            RewriteHelper.ResolveRewrite(Context, out Site site, out string path);

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

            dynamic d = InboundRulesHelper.SectionToJsonModel(site, path);

            return(LocationChanged(InboundRulesHelper.GetSectionLocation(d.id), d));
        }
示例#2
0
        private void ConfigureInboundRules()
        {
            var builder = Environment.Host.RouteBuilder;
            var hal     = Environment.Hal;

            builder.MapWebApiRoute(Defines.InboundRulesSectionResource.Guid, $"{Defines.INBOUND_RULES_SECTION_PATH}/{{id?}}", new { controller = "InboundRulesSection" });
            builder.MapWebApiRoute(Defines.InboundRulesResource.Guid, $"{Defines.INBOUND_RULES_PATH}/{{id?}}", new { controller = "InboundRules" });

            hal.ProvideLink(Defines.InboundRulesSectionResource.Guid, "self", ir => new { href = InboundRulesHelper.GetSectionLocation(ir.id) });
            hal.ProvideLink(Defines.InboundRulesResource.Guid, "self", ir => new { href = InboundRulesHelper.GetRuleLocation(ir.id) });

            // Rewrite -> Section
            hal.ProvideLink(Defines.Resource.Guid, Defines.InboundRulesSectionResource.Name, rewrite => new { href = InboundRulesHelper.GetSectionLocation(rewrite.id) });

            // Section -> Rules
            hal.ProvideLink(Defines.InboundRulesSectionResource.Guid, Defines.InboundRulesResource.Name, inboundRulesSection => new { href = $"/{Defines.INBOUND_RULES_PATH}?{Defines.IDENTIFIER}={inboundRulesSection.id}" });
        }