From 6db505ed91acae0e825ef6f61c958c084d340c19 Mon Sep 17 00:00:00 2001 From: chsakell Date: Sun, 16 Oct 2016 10:22:03 +0300 Subject: [PATCH] fix api URLs refs --- Core/FeedEngine.cs | 6 ++---- Startup.cs | 3 +++ app/shared/services/config.service.ts | 2 +- appsettings.json | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Core/FeedEngine.cs b/Core/FeedEngine.cs index f28561c..52cb1b6 100644 --- a/Core/FeedEngine.cs +++ b/Core/FeedEngine.cs @@ -12,8 +12,6 @@ namespace LiveGameFeed.Core { private ILogger logger; IMatchRepository _matchRepository; - private string _apiURI = "http://localhost:5000/api/"; - public FeedEngine(IMatchRepository matchRepository, ILogger logger) { @@ -51,7 +49,7 @@ namespace LiveGameFeed.Core // Update Score for all clients using (var client = new HttpClient()) { - await client.PutAsJsonAsync(_apiURI + "matches/" + match.Id, score); + await client.PutAsJsonAsync(Startup.API_URL + "matches/" + match.Id, score); } // Update Feed for subscribed only clients @@ -64,7 +62,7 @@ namespace LiveGameFeed.Core }; using (var client = new HttpClient()) { - await client.PostAsJsonAsync(_apiURI + "feeds", _feed); + await client.PostAsJsonAsync(Startup.API_URL + "feeds", _feed); } } } diff --git a/Startup.cs b/Startup.cs index 08d0a46..e9a9a57 100644 --- a/Startup.cs +++ b/Startup.cs @@ -17,6 +17,7 @@ namespace LiveGameFeed { public class Startup { + public static string API_URL = string.Empty; public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() @@ -25,6 +26,8 @@ namespace LiveGameFeed .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); + + API_URL = Configuration["apiURL"]; } public IConfigurationRoot Configuration { get; } diff --git a/app/shared/services/config.service.ts b/app/shared/services/config.service.ts index fd006f7..71cc925 100644 --- a/app/shared/services/config.service.ts +++ b/app/shared/services/config.service.ts @@ -6,7 +6,7 @@ export class ConfigService { _apiURI : string; constructor() { - this._apiURI = 'http://localhost:5000/api/'; + this._apiURI = 'api/'; } getApiURI() { diff --git a/appsettings.json b/appsettings.json index 723c096..779bddb 100644 --- a/appsettings.json +++ b/appsettings.json @@ -6,5 +6,6 @@ "System": "Information", "Microsoft": "Information" } - } + }, + "apiURL" : "http://localhost:5000/api/" }