Пример #1
0
        public async Task <object> Get()
        {
            string hrtUuid = Context.Request.Query[Defines.IDENTIFIER];

            if (string.IsNullOrEmpty(hrtUuid))
            {
                return(NotFound());
            }

            var  id   = new HttpRequestTracingId(hrtUuid);
            Site site = id?.SiteId == null ? null : SiteHelper.GetSite(id.SiteId.Value);

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

            var helper = new TracesHelper(_provider, site);

            IEnumerable <TraceInfo> traces = await helper.GetTraces();

            Context.Response.SetItemsCount(traces.Count());

            return(new {
                traces = traces.Select(t => helper.ToJsonModel(t, Context.Request.GetFields()))
            });
        }
Пример #2
0
        public async Task <object> Get(string id)
        {
            TraceId traceId = new TraceId(id);
            Site    site    = SiteHelper.GetSite(traceId.SiteId);

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

            var helper = new TracesHelper(_provider, site);

            TraceInfo trace = await helper.GetTrace(traceId.Name);

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

            return(helper.ToJsonModel(trace, Context.Request.GetFields()));
        }
Пример #3
0
        private void ConfigureTraces()
        {
            Environment.Host.RouteBuilder.MapWebApiRoute(Defines.TracesResource.Guid, $"{ Defines.TRACES_PATH}/{{id?}}", new { controller = "RequestTraces" });

            Environment.Hal.ProvideLink(Defines.TracesResource.Guid, "self", r => new { href = TracesHelper.GetLocation(r.id) });

            Environment.Hal.ProvideLink(Defines.Resource.Guid, Defines.TracesResource.Name, hrt => new { href = $"/{Defines.TRACES_PATH}?{Defines.IDENTIFIER}={hrt.id}" });
        }