summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs')
-rw-r--r--src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs b/src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs
new file mode 100644
index 00000000..44ed0b6b
--- /dev/null
+++ b/src/SMAPI.Web.LegacyRedirects/Controllers/ModsApiController.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Pathoschild.Http.Client;
+using StardewModdingAPI.Toolkit.Framework.Clients.WebApi;
+
+namespace SMAPI.Web.LegacyRedirects.Controllers
+{
+ /// <summary>Provides an API to perform mod update checks.</summary>
+ [ApiController]
+ [Produces("application/json")]
+ [Route("api/v{version}/mods")]
+ public class ModsApiController : Controller
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Fetch version metadata for the given mods.</summary>
+ /// <param name="model">The mod search criteria.</param>
+ [HttpPost]
+ public async Task<IEnumerable<ModEntryModel>> PostAsync([FromBody] ModSearchModel model)
+ {
+ using IClient client = new FluentClient("https://smapi.io/api");
+
+ Startup.ConfigureJsonNet(client.Formatters.JsonFormatter.SerializerSettings);
+
+ return await client
+ .PostAsync(this.Request.Path)
+ .WithBody(model)
+ .AsArray<ModEntryModel>();
+ }
+ }
+}