Skip to content

Commit

Permalink
Base controller (#194)
Browse files Browse the repository at this point in the history
* Create ApiController.

* Have controllers inherit from ApiController.

* Update openapi.json.
  • Loading branch information
TheTedder authored Sep 13, 2023
1 parent b7bd122 commit c0fbccb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 233 deletions.
3 changes: 1 addition & 2 deletions LeaderboardBackend/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

namespace LeaderboardBackend.Controllers;

[ApiController]
[Route("[controller]")]
public class AccountController : ControllerBase
public class AccountController : ApiController
{
private readonly IUserService _userService;

Expand Down
8 changes: 8 additions & 0 deletions LeaderboardBackend/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.AspNetCore.Mvc;

namespace LeaderboardBackend.Controllers;

[ApiController]
[Produces("application/json")]
[Route("api/[controller]")]
public abstract class ApiController : ControllerBase { }
5 changes: 1 addition & 4 deletions LeaderboardBackend/Controllers/CategoriesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@

namespace LeaderboardBackend.Controllers;

[ApiController]
[Produces("application/json")]
[Route("api/[controller]")]
public class CategoriesController : ControllerBase
public class CategoriesController : ApiController
{
private readonly ICategoryService _categoryService;

Expand Down
4 changes: 1 addition & 3 deletions LeaderboardBackend/Controllers/LeaderboardsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

namespace LeaderboardBackend.Controllers;

[ApiController]
[Route("api/[controller]")]
public class LeaderboardsController : ControllerBase
public class LeaderboardsController : ApiController
{
private readonly ILeaderboardService _leaderboardService;

Expand Down
4 changes: 1 addition & 3 deletions LeaderboardBackend/Controllers/RunsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

namespace LeaderboardBackend.Controllers;

[ApiController]
[Route("api/[controller]")]
public class RunsController : ControllerBase
public class RunsController : ApiController
{
private readonly IRunService _runService;
private readonly ICategoryService _categoryService;
Expand Down
4 changes: 1 addition & 3 deletions LeaderboardBackend/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

namespace LeaderboardBackend.Controllers;

[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
public class UsersController : ApiController
{
private readonly IAuthService _authService;
private readonly IUserService _userService;
Expand Down
Loading

0 comments on commit c0fbccb

Please sign in to comment.