mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 20:08:40 +00:00
Create types directory, create NewsController, extend logging to every status code
This commit is contained in:
parent
4c6e5e07a5
commit
dfb4c7b15b
7 changed files with 79 additions and 3 deletions
14
ProjectLighthouse/Controllers/NetworkSettingsController.cs
Normal file
14
ProjectLighthouse/Controllers/NetworkSettingsController.cs
Normal 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"));
|
||||
}
|
||||
}
|
||||
}
|
27
ProjectLighthouse/Controllers/NewsController.cs
Normal file
27
ProjectLighthouse/Controllers/NewsController.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
23
ProjectLighthouse/Types/NewsEntry.cs
Normal file
23
ProjectLighthouse/Types/NewsEntry.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
14
ProjectLighthouse/Types/NewsImage.cs
Normal file
14
ProjectLighthouse/Types/NewsImage.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue