summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Startup.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-12-26 00:31:36 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-12-26 00:31:36 -0500
commit15d4b6310e3dd15c62f3faedbf1290b2db26fb59 (patch)
tree47d49a9c69628f0df1e688361f46bc5b46b3c0fd /src/SMAPI.Web/Startup.cs
parent5cc5f089b9645a60385ff293b5a7202f260bfc0f (diff)
parentf19cc3aac1a781bf2f2d20bc9577c2fe929b1e96 (diff)
downloadSMAPI-15d4b6310e3dd15c62f3faedbf1290b2db26fb59.tar.gz
SMAPI-15d4b6310e3dd15c62f3faedbf1290b2db26fb59.tar.bz2
SMAPI-15d4b6310e3dd15c62f3faedbf1290b2db26fb59.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/Startup.cs')
-rw-r--r--src/SMAPI.Web/Startup.cs44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs
index 16952124..e5e759e7 100644
--- a/src/SMAPI.Web/Startup.cs
+++ b/src/SMAPI.Web/Startup.cs
@@ -7,6 +7,10 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using StardewModdingAPI.Web.Framework;
+using StardewModdingAPI.Web.Framework.Clients.Chucklefish;
+using StardewModdingAPI.Web.Framework.Clients.GitHub;
+using StardewModdingAPI.Web.Framework.Clients.Nexus;
+using StardewModdingAPI.Web.Framework.Clients.Pastebin;
using StardewModdingAPI.Web.Framework.ConfigModels;
using StardewModdingAPI.Web.Framework.RewriteRules;
@@ -41,9 +45,10 @@ namespace StardewModdingAPI.Web
/// <param name="services">The service injection container.</param>
public void ConfigureServices(IServiceCollection services)
{
+ // init configuration
services
.Configure<ModUpdateCheckConfig>(this.Configuration.GetSection("ModUpdateCheck"))
- .Configure<LogParserConfig>(this.Configuration.GetSection("LogParser"))
+ .Configure<ContextConfig>(this.Configuration.GetSection("Context"))
.Configure<RouteOptions>(options => options.ConstraintMap.Add("semanticVersion", typeof(VersionConstraint)))
.AddMemoryCache()
.AddMvc()
@@ -53,6 +58,41 @@ namespace StardewModdingAPI.Web
options.SerializerSettings.Formatting = Formatting.Indented;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
+
+ // init API clients
+ {
+ ApiClientsConfig api = this.Configuration.GetSection("ApiClients").Get<ApiClientsConfig>();
+ string version = this.GetType().Assembly.GetName().Version.ToString(3);
+ string userAgent = string.Format(api.UserAgent, version);
+
+ services.AddSingleton<IChucklefishClient>(new ChucklefishClient(
+ userAgent: userAgent,
+ baseUrl: api.ChucklefishBaseUrl,
+ modPageUrlFormat: api.ChucklefishModPageUrlFormat
+ ));
+
+ services.AddSingleton<IGitHubClient>(new GitHubClient(
+ baseUrl: api.GitHubBaseUrl,
+ releaseUrlFormat: api.GitHubReleaseUrlFormat,
+ userAgent: userAgent,
+ acceptHeader: api.GitHubAcceptHeader,
+ username: api.GitHubUsername,
+ password: api.GitHubPassword
+ ));
+
+ services.AddSingleton<INexusClient>(new NexusClient(
+ userAgent: api.NexusUserAgent,
+ baseUrl: api.NexusBaseUrl,
+ modUrlFormat: api.NexusModUrlFormat
+ ));
+
+ services.AddSingleton<IPastebinClient>(new PastebinClient(
+ baseUrl: api.PastebinBaseUrl,
+ userAgent: userAgent,
+ userKey: api.PastebinUserKey,
+ devKey: api.PastebinDevKey
+ ));
+ }
}
/// <summary>The method called by the runtime to configure the HTTP request pipeline.</summary>
@@ -89,11 +129,11 @@ namespace StardewModdingAPI.Web
req.Host.Host != "localhost"
&& (req.Host.Host.StartsWith("api.") || req.Host.Host.StartsWith("log."))
&& !req.Path.StartsWithSegments("/content")
+ && !req.Path.StartsWithSegments("/favicon.ico")
))
// shortcut redirects
.Add(new RedirectToUrlRule("^/docs$", "https://stardewvalleywiki.com/Modding:Index"))
- .Add(new RedirectToUrlRule("^/install$", "https://stardewvalleywiki.com/Modding:Installing_SMAPI"))
)
.UseStaticFiles() // wwwroot folder
.UseMvc();