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

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

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

            return(LocationChanged(RewriteMapsHelper.GetSectionLocation(d.id), d));
        }
Beispiel #2
0
        private void ConfigureRewriteMaps()
        {
            var builder = Environment.Host.RouteBuilder;
            var hal     = Environment.Hal;

            builder.MapWebApiRoute(Defines.RewriteMapsSectionResource.Guid, $"{Defines.REWRITE_MAPS_SECTION_PATH}/{{id?}}", new { controller = "RewriteMapsSection" });
            builder.MapWebApiRoute(Defines.RewriteMapsResource.Guid, $"{Defines.REWRITE_MAPS_PATH}/{{id?}}", new { controller = "RewriteMaps" });

            // () -> Self
            hal.ProvideLink(Defines.RewriteMapsSectionResource.Guid, "self", sv => new { href = RewriteMapsHelper.GetSectionLocation(sv.id) });
            hal.ProvideLink(Defines.RewriteMapsResource.Guid, "self", ir => new { href = RewriteMapsHelper.GetMapLocation(ir.id) });

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

            // Section -> Maps
            hal.ProvideLink(Defines.RewriteMapsSectionResource.Guid, Defines.RewriteMapsResource.Name, section => new { href = $"/{Defines.REWRITE_MAPS_PATH}?{Defines.IDENTIFIER}={section.id}" });
        }