summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Controllers/LogParserController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Controllers/LogParserController.cs')
-rw-r--r--src/SMAPI.Web/Controllers/LogParserController.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/SMAPI.Web/Controllers/LogParserController.cs b/src/SMAPI.Web/Controllers/LogParserController.cs
index 454440bb..04a11a82 100644
--- a/src/SMAPI.Web/Controllers/LogParserController.cs
+++ b/src/SMAPI.Web/Controllers/LogParserController.cs
@@ -6,8 +6,8 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using StardewModdingAPI.Web.Framework;
+using StardewModdingAPI.Web.Framework.Clients.Pastebin;
using StardewModdingAPI.Web.Framework.ConfigModels;
-using StardewModdingAPI.Web.Framework.LogParser;
using StardewModdingAPI.Web.ViewModels;
namespace StardewModdingAPI.Web.Controllers
@@ -19,10 +19,10 @@ namespace StardewModdingAPI.Web.Controllers
** Properties
*********/
/// <summary>The log parser config settings.</summary>
- private readonly LogParserConfig Config;
+ private readonly ContextConfig Config;
/// <summary>The underlying Pastebin client.</summary>
- private readonly PastebinClient PastebinClient;
+ private readonly IPastebinClient Pastebin;
/// <summary>The first bytes in a valid zip file.</summary>
/// <remarks>See <a href="https://en.wikipedia.org/wiki/Zip_(file_format)#File_headers"/>.</remarks>
@@ -36,14 +36,12 @@ namespace StardewModdingAPI.Web.Controllers
** Constructor
***/
/// <summary>Construct an instance.</summary>
- /// <param name="configProvider">The log parser config settings.</param>
- public LogParserController(IOptions<LogParserConfig> configProvider)
+ /// <param name="contextProvider">The context config settings.</param>
+ /// <param name="pastebin">The Pastebin API client.</param>
+ public LogParserController(IOptions<ContextConfig> contextProvider, IPastebinClient pastebin)
{
- // init Pastebin client
- this.Config = configProvider.Value;
- string version = this.GetType().Assembly.GetName().Version.ToString(3);
- string userAgent = string.Format(this.Config.PastebinUserAgent, version);
- this.PastebinClient = new PastebinClient(this.Config.PastebinBaseUrl, userAgent, this.Config.PastebinUserKey, this.Config.PastebinDevKey);
+ this.Config = contextProvider.Value;
+ this.Pastebin = pastebin;
}
/***
@@ -52,12 +50,11 @@ namespace StardewModdingAPI.Web.Controllers
/// <summary>Render the log parser UI.</summary>
/// <param name="id">The paste ID.</param>
[HttpGet]
- [Route("")]
[Route("log")]
[Route("log/{id}")]
public ViewResult Index(string id = null)
{
- return this.View("Index", new LogParserModel(this.Config.SectionUrl, id));
+ return this.View("Index", new LogParserModel(this.Config.LogParserUrl, id));
}
/***
@@ -67,9 +64,9 @@ namespace StardewModdingAPI.Web.Controllers
/// <param name="id">The Pastebin paste ID.</param>
[HttpGet, Produces("application/json")]
[Route("log/fetch/{id}")]
- public async Task<GetPasteResponse> GetAsync(string id)
+ public async Task<PasteInfo> GetAsync(string id)
{
- GetPasteResponse response = await this.PastebinClient.GetAsync(id);
+ PasteInfo response = await this.Pastebin.GetAsync(id);
response.Content = this.DecompressString(response.Content);
return response;
}
@@ -78,10 +75,10 @@ namespace StardewModdingAPI.Web.Controllers
/// <param name="content">The log content to save.</param>
[HttpPost, Produces("application/json"), AllowLargePosts]
[Route("log/save")]
- public async Task<SavePasteResponse> PostAsync([FromBody] string content)
+ public async Task<SavePasteResult> PostAsync([FromBody] string content)
{
content = this.CompressString(content);
- return await this.PastebinClient.PostAsync(content);
+ return await this.Pastebin.PostAsync(content);
}