private void ConfigureHandlers() { Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{Defines.PATH}/{{id?}}", new { controller = "handlers" }); Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", handlers => new { href = HandlersHelper.GetLocation(handlers.id) }); // Web Server Environment.Hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => { var id = GetHandlersId(null, null); return(new { href = HandlersHelper.GetLocation(id.Uuid) }); }); // Site Environment.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 = GetHandlersId(s, "/"); return(new { href = HandlersHelper.GetLocation(id.Uuid) }); }); // Application Environment.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 = GetHandlersId(s, appId.Path); return(new { href = HandlersHelper.GetLocation(id.Uuid) }); }); }
public object Get() { Site site = ApplicationHelper.ResolveSite(); string path = ApplicationHelper.ResolvePath(); if (path == null) { return(NotFound()); } dynamic d = HandlersHelper.ToJsonModel(site, path); return(LocationChanged(HandlersHelper.GetLocation(d.id), d)); }