switch to the mods GET endpoint (#336)
This commit is contained in:
parent
c2d8760c56
commit
9ffe0bd371
|
@ -67,27 +67,16 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
/// <param name="modKeys">The namespaced mod keys to search as a comma-delimited array.</param>
|
||||
[HttpGet]
|
||||
public async Task<IDictionary<string, ModInfoModel>> GetAsync(string modKeys)
|
||||
{
|
||||
return await this.PostAsync(new ModSearchModel
|
||||
{
|
||||
ModKeys = modKeys?.Split(',').Select(p => p.Trim()).ToArray() ?? new string[0]
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Fetch version metadata for the given mods.</summary>
|
||||
/// <param name="search">The search options.</param>
|
||||
[HttpPost]
|
||||
public async Task<IDictionary<string, ModInfoModel>> PostAsync([FromBody] ModSearchModel search)
|
||||
{
|
||||
// sort & filter keys
|
||||
string[] modKeys = (search.ModKeys ?? new string[0])
|
||||
string[] modKeysArray = (modKeys?.Split(',').Select(p => p.Trim()).ToArray() ?? new string[0])
|
||||
.Distinct(StringComparer.CurrentCultureIgnoreCase)
|
||||
.OrderBy(p => p, StringComparer.CurrentCultureIgnoreCase)
|
||||
.ToArray();
|
||||
|
||||
// fetch mod info
|
||||
IDictionary<string, ModInfoModel> result = new Dictionary<string, ModInfoModel>(StringComparer.CurrentCultureIgnoreCase);
|
||||
foreach (string modKey in modKeys)
|
||||
foreach (string modKey in modKeysArray)
|
||||
{
|
||||
// parse mod key
|
||||
if (!this.TryParseModKey(modKey, out string vendorKey, out string modID))
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
namespace StardewModdingAPI.Web.Models
|
||||
{
|
||||
/// <summary>Metadata for mods to look up.</summary>
|
||||
internal class ModSearchModel
|
||||
{
|
||||
/// <summary>The namespaced mod keys to search.</summary>
|
||||
public string[] ModKeys { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue