Create types directory, create NewsController, extend logging to every status code

This commit is contained in:
jvyden 2021-10-06 01:50:49 -04:00
commit dfb4c7b15b
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
7 changed files with 79 additions and 3 deletions

View file

@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Controllers {
[ApiController]
[Route("LITTLEBIGPLANETPS3_XML/network_settings.nws")]
[Produces("text/xml")]
public class NetworkSettingsController : ControllerBase {
[HttpGet]
public IActionResult Get() {
return this.Ok(LbpSerializer.GetBlankElement("networkSettings"));
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Controllers {
[ApiController]
[Route("LITTLEBIGPLANETPS3_XML/news")]
[Produces("text/xml")]
public class NewsController : ControllerBase {
[HttpGet]
public IActionResult Get() {
string newsEntry = LbpSerializer.GetStringElement("item", new NewsEntry {
Category = "no_category",
Summary = "test summary",
Image = new NewsImage {
Hash = "4947269c5f7061b27225611ee58a9a91a8031bbe",
Alignment = "right"
},
Id = 1,
Title = "Test Title",
Text = "Test Text",
Date = 1348755214000
}.Serialize());
return this.Ok(LbpSerializer.GetStringElement("news", newsEntry));
}
}
}

View file

@ -37,9 +37,7 @@ namespace ProjectLighthouse {
app.Use(async (context, next) => {
await next();
if(context.Response.StatusCode == 404) {
Console.WriteLine($"404: {context.Request.Method} {context.Request.Path}");
}
Console.WriteLine($"{context.Response.StatusCode}: {context.Request.Method} {context.Request.Path}");
});
app.UseRouting();

View file

@ -0,0 +1,23 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse {
public class NewsEntry {
public int Id { get; set; }
public string Title { get; set; }
public string Summary { get; set; }
public string Text { get; set; }
public NewsImage Image { get; set; }
public string Category { get; set; }
public long Date { get; set; }
public string Serialize() {
return LbpSerializer.GetStringElement("id", Id) +
LbpSerializer.GetStringElement("title", Title) +
LbpSerializer.GetStringElement("summary", Summary) +
LbpSerializer.GetStringElement("text", Text) +
LbpSerializer.GetStringElement("date", Date) +
Image.Serialize() +
LbpSerializer.GetStringElement("category", Category);
}
}
}

View file

@ -0,0 +1,14 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse {
public class NewsImage {
public string Hash { get; set; }
public string Alignment { get; set; }
public string Serialize() {
return LbpSerializer.GetStringElement("image",
LbpSerializer.GetStringElement("hash", Hash) +
LbpSerializer.GetStringElement("alignment", Alignment));
}
}
}