public async Task <IActionResult> GetAsync(Guid guid) { try { string applicationName = serviceContext.CodePackageActivationContext.ApplicationName; string serviceName = configSettings.QuoteServiceName; string restUrl = "/api/Quotes/" + guid; var config = ServiceFabricConfig.Initialize(applicationName, serviceName, restUrl); HttpResponseMessage response = ServiceFabricAPIUtility.Get(config).Result; if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(this.StatusCode((int)response.StatusCode)); } return(this.Ok(await response.Content.ReadAsStringAsync())); } catch (Exception e) { throw e; } }
public async Task <IActionResult> QuotaHealthCheck() { try { string applicationName = serviceContext.CodePackageActivationContext.ApplicationName; string serviceName = configSettings.CurrencyServiceName; string restUrl = "/api/Currencies/Heartbeat"; int reverseProxyPort = configSettings.ReverseProxyPort; var config = ServiceFabricConfig.Initialize(applicationName, serviceName, restUrl, reverseProxyPort); HttpResponseMessage response = ServiceFabricAPIUtility.GetReverseProxyAsync(config).Result; if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(this.StatusCode((int)response.StatusCode)); } return(this.Ok(await response.Content.ReadAsStringAsync())); } catch (Exception e) { throw e; } }
public async Task <IActionResult> PostAsync([FromBody] GatewayQuoteRequest request) { try { string stringData = JsonConvert.SerializeObject(request); var requestContent = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json"); string applicationName = serviceContext.CodePackageActivationContext.ApplicationName; string serviceName = this.configSettings.QuoteServiceName; string restUrl = "/api/quotes"; var config = ServiceFabricConfig.Initialize(applicationName, serviceName, restUrl); HttpResponseMessage response = ServiceFabricAPIUtility.Post(requestContent, config).Result; if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(this.StatusCode((int)response.StatusCode)); } return(Ok(await response.Content.ReadAsStringAsync())); } catch (Exception e) { throw e; } }