aboutsummaryrefslogtreecommitdiff
path: root/Transactional Emails/TEmailEntryPoint.cs
blob: 97b9c864550638d3843a2612bbea7c90cf70c071 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;

using Emails.Transactional.Endpoints;

using Minio;
using Minio.DataModel.Tracing;

using VNLib.Utils.Logging;
using VNLib.Plugins;
using VNLib.Plugins.Extensions.Loading.Routing;

namespace Emails.Transactional
{
    public class TEmailEntryPoint : PluginBase
    {
        public override string PluginName => "Emails.Transactional";

        internal class ReqLogger : IRequestLogger
        {
            private readonly ILogProvider logProvider;

            public ReqLogger(ILogProvider log)
            {
                logProvider = log;
            }

            public void LogRequest(RequestToLog requestToLog, ResponseToLog responseToLog, double durationMs)
            {
                logProvider.Debug("S3 result\n{method} {uri} HTTP {ms}ms\nHTTP {status} {message}\n{content}",
                    requestToLog.method, requestToLog.resource, durationMs,
                    responseToLog.statusCode, responseToLog.errorMessage, responseToLog.content
                    );
            }
        }

        protected override void OnLoad()
        {
            try
            {
                //Route send oauth endpoint
                this.Route<SendEndpoint>();

                Log.Information("Plugin loaded");
            }
            catch (KeyNotFoundException kne)
            {
                Log.Warn("Missing required configuration keys {err}", kne.Message);
            }
        }
     

        protected override void OnUnLoad()
        {
            Log.Information("Plugin unloaded");
        }

        protected override void ProcessHostCommand(string cmd)
        {
            throw new NotImplementedException();
        }
    }
}