Skip to content

Commit

Permalink
chore: switch to primary constructor for api controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Oct 7, 2024
1 parent f88cc78 commit 55fc933
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
20 changes: 7 additions & 13 deletions Shokofin/Web/ShokoApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,18 @@ namespace Shokofin.Web;
/// <summary>
/// Shoko API Host Web Controller.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="ShokoApiController"/> class.
/// </remarks>
/// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param>
[ApiController]
[Route("Plugin/Shokofin/Host")]
[Produces(MediaTypeNames.Application.Json)]
public class ShokoApiController : ControllerBase
public class ShokoApiController(ILogger<ShokoApiController> logger, ShokoAPIClient apiClient) : ControllerBase
{
private readonly ILogger<ShokoApiController> Logger;
private readonly ILogger<ShokoApiController> Logger = logger;

private readonly ShokoAPIClient APIClient;

/// <summary>
/// Initializes a new instance of the <see cref="ShokoApiController"/> class.
/// </summary>
/// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param>
public ShokoApiController(ILogger<ShokoApiController> logger, ShokoAPIClient apiClient)
{
Logger = logger;
APIClient = apiClient;
}
private readonly ShokoAPIClient APIClient = apiClient;

/// <summary>
/// Try to get the version of the server.
Expand Down
18 changes: 6 additions & 12 deletions Shokofin/Web/SignalRApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,17 @@ namespace Shokofin.Web;
/// <summary>
/// Shoko SignalR Control Web Controller.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="SignalRApiController"/> class.
/// </remarks>
[ApiController]
[Route("Plugin/Shokofin/SignalR")]
[Produces(MediaTypeNames.Application.Json)]
public class SignalRApiController : ControllerBase
public class SignalRApiController(ILogger<SignalRApiController> logger, SignalRConnectionManager connectionManager) : ControllerBase
{
private readonly ILogger<SignalRApiController> Logger;
private readonly ILogger<SignalRApiController> Logger = logger;

private readonly SignalRConnectionManager ConnectionManager;

/// <summary>
/// Initializes a new instance of the <see cref="SignalRApiController"/> class.
/// </summary>
public SignalRApiController(ILogger<SignalRApiController> logger, SignalRConnectionManager connectionManager)
{
Logger = logger;
ConnectionManager = connectionManager;
}
private readonly SignalRConnectionManager ConnectionManager = connectionManager;

/// <summary>
/// Get the current status of the connection to Shoko Server.
Expand Down

0 comments on commit 55fc933

Please sign in to comment.