From 3e20e41565ad0b62b5581b52ff6ed613225e58c5 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 10 Aug 2023 22:57:13 +0100 Subject: [PATCH] refactor: use HttpGet for api routes --- OliverBooth/Controllers/BlogApiController.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OliverBooth/Controllers/BlogApiController.cs b/OliverBooth/Controllers/BlogApiController.cs index 308cbd8..198179f 100644 --- a/OliverBooth/Controllers/BlogApiController.cs +++ b/OliverBooth/Controllers/BlogApiController.cs @@ -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();