public async Task <IActionResult> Get([FromRoute(Name = "data")] string data, [FromRoute(Name = "endpoint")] Guid endpointId) { var endpoint = await EndpointService.FindById(endpointId, true); var outputData = endpoint.OutputData; //TODO: get rid of try/catch try { var json = JsonConvert.DeserializeObject(endpoint.OutputData); HttpContext.Response.Headers["Content-Type"] = "application/json; charset=utf-8"; } catch { } HttpContext.Response.StatusCode = endpoint.OutputStatusCode; endpoint.OutputData = null; await LoggingService.Create(new RequestLog { Received = data, Endpoint = endpoint }); if (endpoint.CallbackType == CallbackType.Asynchronous) { await Task.Run(async() => await AsyncRequestService.Call(endpoint)); } return(Content(outputData)); }
public async Task <IActionResult> Error([FromRoute(Name = "data")] string data, [FromRoute(Name = "endpoint")] string endpointRaw, [FromRoute(Name = "errorMessage")] string errorMessage) { var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; var endpoint = JsonConvert.DeserializeObject <Endpoint>(endpointRaw, settings); await LoggingService.Create(new RequestLog { Received = data, Endpoint = endpoint, IsError = true }); return(BadRequest(errorMessage)); }
public async Task Invoke(HttpContext context, LoggingService loggingService) { var stopwatch = new Stopwatch(); stopwatch.Start(); await _next(context); try { loggingService.Create(new Log { Elapsed = stopwatch.ElapsedMilliseconds, Path = context.Request.Path }); } catch (Exception e) { Console.WriteLine(e.Message); } }
public ActionResult <Log> Create(Log log) { _loggingService.Create(log); return(CreatedAtRoute("Getlog", new { id = log.Id.ToString() }, log)); }