From 040d73492a6c79ec5706639c0fe851a9921d6178 Mon Sep 17 00:00:00 2001 From: exyi Date: Sun, 27 Sep 2020 20:36:00 +0000 Subject: [PATCH] Add POST to tasks.json --- server/Ksp.WebServer/Controllers/TasksController.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/Ksp.WebServer/Controllers/TasksController.cs b/server/Ksp.WebServer/Controllers/TasksController.cs index 80dce8d..9c7c1d4 100644 --- a/server/Ksp.WebServer/Controllers/TasksController.cs +++ b/server/Ksp.WebServer/Controllers/TasksController.cs @@ -22,10 +22,21 @@ namespace Ksp.WebServer.Controllers this.logger = logger; } + string TasksJsonFile => Path.Combine(env.ContentRootPath, "../../tasks.json"); + [HttpGet] public IActionResult Get() { - return this.PhysicalFile(Path.Combine(env.ContentRootPath, "../../tasks.json"), "text/json"); + return this.PhysicalFile(TasksJsonFile, "text/json"); + } + + [HttpPost] + public async Task Post() + { + // TODO: auth org + using var rdr = new StreamReader(HttpContext.Request.Body); + await System.IO.File.WriteAllTextAsync(TasksJsonFile, await rdr.ReadToEndAsync()); + return Ok(); } } }