-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Api Versioning, Add Exception Handler.
Add Base Controller and config MediatR.
- Loading branch information
1 parent
587b51e
commit e656f1f
Showing
7 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using MediatR; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace SwiftLink.Presentation.Controllers; | ||
|
||
[Route("api/v{v:apiVersion}/[controller]/[action]")] | ||
[ApiController] | ||
public abstract class BaseController : Controller | ||
{ | ||
private ISender? _mediatR; | ||
protected ISender MediatR => _mediatR ??= HttpContext.RequestServices.GetRequiredService<ISender>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Asp.Versioning; | ||
using Microsoft.AspNetCore.Mvc; | ||
using SwiftLink.Application.UseCases.Links.GenerateCommand; | ||
|
||
namespace SwiftLink.Presentation.Controllers; | ||
|
||
[ApiVersion("1.0")] | ||
public class LinkController : BaseController | ||
{ | ||
[HttpPost] | ||
public IActionResult Generate([FromBody] GenerateShortCodeCommand command) | ||
{ | ||
return Ok(MediatR.Send(command)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters