public override void Start() { var host = Environment.Host; var hal = Environment.Hal; host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "compression" }); // Self hal.ProvideLink(Defines.Resource.Guid, "self", comp => new { href = CompressionHelper.GetLocation(comp.id) }); // Web Server hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => { var id = new CompressionId(null, null, CompressionHelper.IsSectionLocal(null, null)); return(new { href = CompressionHelper.GetLocation(id.Uuid) }); }); // Site 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 = new CompressionId(siteId.Id, "/", CompressionHelper.IsSectionLocal(s, "/")); return(new { href = CompressionHelper.GetLocation(id.Uuid) }); }); // Application 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 = new CompressionId(appId.SiteId, appId.Path, CompressionHelper.IsSectionLocal(s, appId.Path)); return(new { href = CompressionHelper.GetLocation(id.Uuid) }); }); }
public async Task <object> Post() { if (CompressionHelper.IsStaticEnabled() && CompressionHelper.IsDynamicEnabled()) { throw new AlreadyExistsException(DISPLAY_NAME); } await CompressionHelper.SetFeatureEnabled(true); dynamic compression = CompressionHelper.ToJsonModel(null, null); return(Created(CompressionHelper.GetLocation(compression.id), compression)); }
public object Get() { Site site = ApplicationHelper.ResolveSite(); string path = ApplicationHelper.ResolvePath(); if (path == null) { return(NotFound()); } dynamic d = CompressionHelper.ToJsonModel(site, path); return(LocationChanged(CompressionHelper.GetLocation(d.id), d)); }