Publishing gives valid response

This commit is contained in:
jvyden 2021-10-06 18:47:40 -04:00
commit 15f974fba1
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -3,24 +3,35 @@ using System.IO;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
namespace ProjectLighthouse.Controllers {
[ApiController]
[Route("LITTLEBIGPLANETPS3_XML/")]
[Produces("text/plain")]
[Produces("text/xml")]
public class PublishController : ControllerBase {
[HttpPost("startPublish")]
public async Task<IActionResult> StartPublish() {
Slot slot = await this.GetSlotFromBody();
return this.Ok(LbpSerializer.TaggedStringElement("slot", "", "type", "user"));
}
[HttpPost("publish")]
public async Task<IActionResult> Publish() {
string bodyString = await new StreamReader(Request.Body).ReadToEndAsync();
return this.Ok(LbpSerializer.TaggedStringElement("slot", bodyString, "type", "user"));
}
public async Task<Slot> GetSlotFromBody() {
Request.Body.Position = 0;
string bodyString = await new StreamReader(Request.Body).ReadToEndAsync();
XmlSerializer serializer = new(typeof(Slot));
Slot slot = (Slot)serializer.Deserialize(new StringReader(bodyString));
Console.WriteLine(slot);
return this.Ok();
return slot;
}
}
}