refactor: use HttpGet for api routes

This commit is contained in:
Oliver Booth 2023-08-10 22:57:13 +01:00
parent d3958fc22c
commit 3e20e41565
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 4 additions and 4 deletions

View File

@ -16,14 +16,14 @@ public sealed class BlogApiController : ControllerBase
_blogService = blogService;
}
[Route("count")]
[HttpGet("count")]
public IActionResult Count()
{
if (!ValidateReferer()) return NotFound();
return Ok(new { count = _blogService.AllPosts.Count });
}
[Route("all/{skip:int?}/{take:int?}")]
[HttpGet("all/{skip:int?}/{take:int?}")]
public IActionResult GetAllBlogPosts(int skip = 0, int take = -1)
{
if (!ValidateReferer()) return NotFound();
@ -52,7 +52,7 @@ public sealed class BlogApiController : ControllerBase
}));
}
[Route("author/{id:int}")]
[HttpGet("author/{id:int}")]
public IActionResult GetAuthor(int id)
{
if (!ValidateReferer()) return NotFound();
@ -64,7 +64,7 @@ public sealed class BlogApiController : ControllerBase
avatarHash = author.AvatarHash,
});
}
private bool ValidateReferer()
{
var referer = Request.Headers["Referer"].ToString();