mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add ReloadController.cs allows the discovery and reloading of a specified mod via HTTP API
This commit is contained in:
parent
738d62757c
commit
30fba90e9f
1 changed files with 34 additions and 0 deletions
34
Penumbra/Api/ReloadController.cs
Normal file
34
Penumbra/Api/ReloadController.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using EmbedIO.Routing;
|
||||
using EmbedIO;
|
||||
using EmbedIO.WebApi;
|
||||
using Penumbra.Api.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace Penumbra.Api {
|
||||
public class ReloadController : WebApiController {
|
||||
private readonly Penumbra _penumbra;
|
||||
public ReloadController( Penumbra penumbra )
|
||||
=> _penumbra = penumbra;
|
||||
|
||||
[Route( HttpVerbs.Post, "/reload" )]
|
||||
public async Task Reload() {
|
||||
var data = await HttpContext.GetRequestDataAsync<ReloadData>();
|
||||
if( !string.IsNullOrEmpty( data.ModPath ) && !string.IsNullOrEmpty( data.ModName ) ) {
|
||||
if(Directory.Exists( data.ModPath ) ) {
|
||||
_penumbra.Api.AddMod( data.ModPath );
|
||||
}
|
||||
_penumbra.Api.ReloadMod( data.ModPath, data.ModName );
|
||||
}
|
||||
}
|
||||
|
||||
public class ReloadData {
|
||||
public string ModPath { get; set; } = string.Empty;
|
||||
public string ModName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue