Esempio n. 1
0
        private void ConfigureHttpResponseHeaders()
        {
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.Resource.Guid, $"{ Defines.PATH}/{{id?}}", new { controller = "HttpResponseHeaders" });

            Environment.Hal.ProvideLink(Defines.Resource.Guid, "self", respHeader => new { href = HttpResponseHeadersHelper.GetLocation(respHeader.id) });

            // Web Server
            Environment.Hal.ProvideLink(WebServer.Defines.Resource.Guid, Defines.Resource.Name, _ => {
                var id = GetHttpResponseHeadersId(null, null);
                return(new { href = HttpResponseHeadersHelper.GetLocation(id.Uuid) });
            });

            // Sites
            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     = GetHttpResponseHeadersId(s, "/");
                return(new { href = HttpResponseHeadersHelper.GetLocation(id.Uuid) });
            });

            // Applications
            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    = GetHttpResponseHeadersId(s, appId.Path);
                return(new { href = HttpResponseHeadersHelper.GetLocation(id.Uuid) });
            });
        }
Esempio n. 2
0
        public object Get()
        {
            Site   site = ApplicationHelper.ResolveSite();
            string path = ApplicationHelper.ResolvePath();

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

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

            return(LocationChanged(HttpResponseHeadersHelper.GetLocation(d.id), d));
        }