public async Task <IActionResult> JoinCallAsync([FromBody] JoinCallBody joinCallBody) { var call = await this.bot.JoinCallAsync(joinCallBody).ConfigureAwait(false); var serviceURL = new UriBuilder($"{this.Request.Scheme}://{this.Request.Host}"); serviceURL.Port = this.botOptions.BotBaseUrl.Port + this.statelessServiceContext.NodeInstance(); return(this.Ok(new JoinCallResponseBody { CallURL = serviceURL + HttpRouteConstants.CallRoute.Replace("{callId}", call.Id), CallSnapshotURL = serviceURL + HttpRouteConstants.OnSnapshotRoute.Replace("{callId}", call.Id), CallHueURL = serviceURL + HttpRouteConstants.OnHueRoute.Replace("{callId}", call.Id), CallsURL = serviceURL + HttpRouteConstants.Calls, ServiceLogsURL = serviceURL + HttpRouteConstants.Logs + call.Id, })); }
public async Task <IActionResult> JoinCallAsync([FromBody] JoinCallBody joinCallBody) { try { var call = await _botService.JoinCallAsync(joinCallBody).ConfigureAwait(false); var callPath = $"/{HttpRouteConstants.CallRoute.Replace("{callLegId}", call.Id)}"; var callUri = $"{_settings.ServiceCname}{callPath}"; var values = new JoinURLResponse() { Call = callUri, CallId = call.Id, ScenarioId = call.ScenarioId, Logs = callUri.Replace("/calls/", "/logs/") }; var json = JsonConvert.SerializeObject(values); return(Ok(values)); } catch (ServiceException e) { HttpResponseMessage response = (int)e.StatusCode >= 300 ? new HttpResponseMessage(e.StatusCode) : new HttpResponseMessage(HttpStatusCode.InternalServerError); if (e.ResponseHeaders != null) { foreach (var responseHeader in e.ResponseHeaders) { response.Headers.TryAddWithoutValidation(responseHeader.Key, responseHeader.Value); } } response.Content = new StringContent(e.ToString()); return(StatusCode(500, e.ToString())); } catch (Exception e) { _logger.Error(e, $"Received HTTP {this.Request.Method}, {this.Request.Path.Value}"); return(StatusCode(500, e.Message)); } }