wabbajack/Wabbajack.BuildServer/Controllers/AControllerBase.cs

39 lines
988 B
C#
Raw Normal View History

using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
2020-01-08 04:41:50 +00:00
using Microsoft.Extensions.Logging;
using Wabbajack.BuildServer.Model.Models;
2020-01-08 04:41:50 +00:00
using Wabbajack.BuildServer.Models;
using Wabbajack.Common;
2020-01-08 04:41:50 +00:00
namespace Wabbajack.BuildServer.Controllers
{
2020-01-10 02:06:11 +00:00
[ApiController]
2020-01-08 04:41:50 +00:00
public abstract class AControllerBase<T> : ControllerBase
{
2020-01-10 02:06:11 +00:00
protected readonly ILogger<T> Logger;
protected readonly SqlService SQL;
2020-01-08 04:41:50 +00:00
protected AControllerBase(ILogger<T> logger, SqlService sql)
2020-01-08 04:41:50 +00:00
{
Logger = logger;
SQL = sql;
}
protected async Task Metric(string verb, string subject)
{
await SQL.IngestMetric(new Metric
{
MetricsKey = Request?.Headers[Consts.MetricsKeyHeader].FirstOrDefault() ?? "",
Subject = subject,
Action = verb,
Timestamp = DateTime.UtcNow
});
2020-01-08 04:41:50 +00:00
}
2020-01-08 04:41:50 +00:00
}
}