refactor: move blog api controller to project root

This commit is contained in:
Oliver Booth 2023-08-11 16:32:11 +01:00
parent e060ab4dea
commit 54f3706ba0
Signed by: oliverbooth
GPG Key ID: 725DB725A0D9EE61
1 changed files with 7 additions and 6 deletions

View File

@ -3,14 +3,14 @@ using Microsoft.AspNetCore.Mvc;
using OliverBooth.Data.Blog;
using OliverBooth.Services;
namespace OliverBooth.Areas.Api.Controllers;
namespace OliverBooth.Controllers;
/// <summary>
/// Represents a controller for the blog API.
/// </summary>
[Controller]
[Area("api")]
[Route("blog")]
[ApiController]
[Route("api/blog")]
[Produces("application/json")]
public sealed class BlogApiController : ControllerBase
{
private readonly BlogService _blogService;
@ -24,7 +24,7 @@ public sealed class BlogApiController : ControllerBase
_blogService = blogService;
}
[HttpGet("count")]
[Route("count")]
public IActionResult Count()
{
if (!ValidateReferer()) return NotFound();
@ -69,6 +69,7 @@ public sealed class BlogApiController : ControllerBase
return Ok(new
{
id = author.Id,
name = author.Name,
avatarHash = author.AvatarHash,
});
@ -77,6 +78,6 @@ public sealed class BlogApiController : ControllerBase
private bool ValidateReferer()
{
var referer = Request.Headers["Referer"].ToString();
return referer.StartsWith(Url.PageLink("/Blog/Index")!);
return referer.StartsWith(Url.PageLink("/index",values: new{area="blog"})!);
}
}