public static LogListDto WithLinks( this LogListDto dto, IUrlHelper urlHelper, ApiVersion apiVersion) { dto.Links = new List <LinkDto> { new LinkDto( urlHelper.Link(nameof(LogsController.GetLogs), new { dto.start, dto.end, version = apiVersion.ToString() }), "self", System.Net.Http.HttpMethod.Get.Method) }; return(dto); }
public ActionResult GetLogs( [FromQuery(Name = "start")] DateTimeOffset start, [FromQuery(Name = "end")] DateTimeOffset end, ApiVersion apiVersion) { LogListDto logsDto = new LogListDto { start = start, end = end, Logs = MemorySink .GetInstance() .GetLogs(start, end) .Select(logEvent => new LogDto { Timestamp = logEvent.Timestamp, Message = logEvent.RenderMessage(), Level = logEvent.Level.ToString() }) .OrderBy(logDto => logDto.Timestamp), }; return(Ok(logsDto.WithLinks(Url, apiVersion))); }