-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from MichaelEbert/multimerge
Multimerge
- Loading branch information
Showing
18 changed files
with
506 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Routing; | ||
using Microsoft.VisualBasic; | ||
using System; | ||
using System.Net.Http; | ||
using System.Text.Json; | ||
using System.Text.Json.Nodes; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
|
||
namespace ShareApi.Controllers | ||
{ | ||
[ApiController] | ||
[Route("share/{url}/d/{**jsonPath}")] | ||
public class DataController : Controller | ||
{ | ||
|
||
|
||
[HttpGet] | ||
public ActionResult<string> HandleGet(string url, string? jsonPath) | ||
{ | ||
var saveEditor = new SaveDataEditor(url); | ||
return Ok(saveEditor.HandleData(new HttpMethod(Request.Method), jsonPath, null)); | ||
} | ||
|
||
[HttpPut] | ||
[HttpPost] | ||
public ActionResult<string> Handle(ProgressUpdate update, string url, string? jsonPath) | ||
{ | ||
ProgressUpdateValidator.Validate(update, out ValidationFailedReason validationFailedReason); | ||
if(validationFailedReason != ValidationFailedReason.NONE) | ||
{ | ||
ModelState.AddModelError("error", validationFailedReason.ToString()); | ||
return BadRequest(ModelState); | ||
} | ||
var saveEditor = new SaveDataEditor(url, update); | ||
if(saveEditor.ReadOnly) | ||
{ | ||
return Unauthorized(); | ||
} | ||
return Ok(saveEditor.HandleData(new HttpMethod(Request.Method), jsonPath, JsonNode.Parse(update.SaveData))); | ||
} | ||
} | ||
|
||
public class JsonProxyNode | ||
{ | ||
public JsonNode? parent; | ||
public string Name; | ||
public JsonNode? contents; | ||
|
||
public JsonProxyNode(string name) | ||
{ | ||
this.Name = name; | ||
} | ||
|
||
/// <summary> | ||
/// Update the json tree and return the changed tree. | ||
/// </summary> | ||
/// <returns></returns> | ||
public JsonNode Commit() | ||
{ | ||
if (parent != null) | ||
{ | ||
if (parent.GetValueKind() == System.Text.Json.JsonValueKind.Object) | ||
{ | ||
parent[Name] = contents; | ||
} | ||
else | ||
{ | ||
parent[int.Parse(Name)] = contents; | ||
} | ||
|
||
return parent.Root ?? parent; | ||
} | ||
else | ||
{ | ||
return contents; | ||
} | ||
|
||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.