Skip to content

Commit

Permalink
More udpates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Sep 11, 2024
1 parent ef26abe commit cd7a20c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ namespace Serval.ApiServer.Controllers;
public class StatusController(
HealthCheckService healthCheckService,
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IWebHostEnvironment env,
IConfiguration configuration,
ILogger<StatusController> logger
) : ServalControllerBase(authService)
) : ServalControllerBase(authService, bugsnagClient)
{
private readonly HealthCheckService _healthCheckService = healthCheckService;
private readonly IWebHostEnvironment _env = env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
[FeatureGate("Assessment")]
public class AssessmentEnginesController(
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IEngineService engineService,
IJobService jobService,
IResultService resultService,
IOptionsMonitor<ApiOptions> apiOptions,
IUrlService urlService
) : ServalControllerBase(authService)
) : ServalControllerBase(authService, bugsnagClient)
{
private static readonly JsonSerializerOptions ObjectJsonSerializerOptions =
new() { Converters = { new ObjectToInferredTypesConverter() } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
[OpenApiTag("Files")]
public class DataFilesController(
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IDataFileService dataFileService,
IUrlService urlService
) : ServalControllerBase(authService)
) : ServalControllerBase(authService, bugsnagClient)
{
private readonly IDataFileService _dataFileService = dataFileService;
private readonly IUrlService _urlService = urlService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class BugsnagExceptionFilter : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
{
context.HttpContext.RequestServices.GetService<IClient>()?.Notify(context.Exception);
context.HttpContext.RequestServices.GetService<Bugsnag.IClient>()?.Notify(context.Exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[ApiController]
[Produces("application/json")]
[TypeFilter(typeof(BugsnagExceptionFilter))]
[TypeFilter(typeof(OperationCancelledExceptionFilter))]
[TypeFilter(typeof(NotSupportedExceptionFilter))]
[TypeFilter(typeof(ServiceUnavailableExceptionFilter))]
Expand All @@ -10,10 +11,11 @@
[TypeFilter(typeof(NotFoundExceptionFilter))]
[TypeFilter(typeof(ForbiddenExceptionFilter))]
[TypeFilter(typeof(BadRequestExceptionFilter))]
public abstract class ServalControllerBase(IAuthorizationService authService, IClient bugsnagClient) : Controller
public abstract class ServalControllerBase(IAuthorizationService authService, Bugsnag.IClient bugsnagClient)
: Controller
{
private readonly IAuthorizationService _authService = authService;
protected readonly IClient BugsnagClient = bugsnagClient;
protected readonly Bugsnag.IClient BugsnagClient = bugsnagClient;

protected string Owner => User.Identity!.Name!;

Expand Down
1 change: 0 additions & 1 deletion src/Serval/src/Serval.Shared/Usings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
global using System.Diagnostics;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using Bugsnag;
global using Grpc.Core;
global using Grpc.Net.ClientFactory;
global using Microsoft.AspNetCore.Authorization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
[ApiVersion(1.0)]
[Route("api/v{version:apiVersion}/translation/engine-types")]
[OpenApiTag("Translation Engines")]
public class TranslationEngineTypesController(IAuthorizationService authService, IEngineService engineService)
: ServalControllerBase(authService)
public class TranslationEngineTypesController(
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IEngineService engineService
) : ServalControllerBase(authService, bugsnagClient)
{
private readonly IEngineService _engineService = engineService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
[OpenApiTag("Translation Engines")]
public class TranslationEnginesController(
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IEngineService engineService,
IBuildService buildService,
IPretranslationService pretranslationService,
IOptionsMonitor<ApiOptions> apiOptions,
IUrlService urlService,
ILogger<TranslationEnginesController> logger
) : ServalControllerBase(authService)
) : ServalControllerBase(authService, bugsnagClient)
{
private static readonly JsonSerializerOptions ObjectJsonSerializerOptions =
new() { Converters = { new ObjectToInferredTypesConverter() } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

[ApiVersion(1.0)]
[Route("api/v{version:apiVersion}/hooks")]
public class WebhooksController(IAuthorizationService authService, IWebhookService hookService, IUrlService urlService)
: ServalControllerBase(authService)
public class WebhooksController(
IAuthorizationService authService,
Bugsnag.IClient bugsnagClient,
IWebhookService hookService,
IUrlService urlService
) : ServalControllerBase(authService, bugsnagClient)
{
private readonly IWebhookService _hookService = hookService;
private readonly IUrlService _urlService = urlService;
Expand Down

0 comments on commit cd7a20c

Please sign in to comment.