diff --git a/src/Http/Wolverine.Http.Tests/endpoint_adds_requesttype_audit_tags_to_activity.cs b/src/Http/Wolverine.Http.Tests/endpoint_adds_requesttype_audit_tags_to_activity.cs new file mode 100644 index 000000000..d6f630fa4 --- /dev/null +++ b/src/Http/Wolverine.Http.Tests/endpoint_adds_requesttype_audit_tags_to_activity.cs @@ -0,0 +1,25 @@ +using JasperFx.CodeGeneration; +using JasperFx.Core; +using JasperFx.Core.Reflection; +using Microsoft.AspNetCore.Http; +using Shouldly; +using WolverineWebApi; + +namespace Wolverine.Http.Tests; + +public class endpoint_adds_requesttype_audit_tags_to_activity : IntegrationContext +{ + public endpoint_adds_requesttype_audit_tags_to_activity(AppFixture fixture) : base(fixture) + { + } + + [Fact] + public void finds_audit_members_from_attributes() + { + var chain = HttpChains.ChainFor("POST", "/auditable/empty"); + + chain.AuditedMembers.Single() + .MemberName.ShouldBe(nameof(AuditablePostBody.Id)); + } + +} \ No newline at end of file diff --git a/src/Http/Wolverine.Http/HttpChain.Codegen.cs b/src/Http/Wolverine.Http/HttpChain.Codegen.cs index fa79335ec..35ad1acd6 100644 --- a/src/Http/Wolverine.Http/HttpChain.Codegen.cs +++ b/src/Http/Wolverine.Http/HttpChain.Codegen.cs @@ -8,13 +8,15 @@ using Microsoft.AspNetCore.Routing; using Wolverine.Http.CodeGen; using Wolverine.Http.Resources; -using Wolverine.Persistence; +using Wolverine.Logging; using Wolverine.Runtime.Handlers; namespace Wolverine.Http; public partial class HttpChain { + internal string? SourceCode => _generatedType?.SourceCode; + void ICodeFile.AssembleTypes(GeneratedAssembly assembly) { assembly.UsingNamespaces!.Fill(typeof(RoutingHttpContextExtensions).Namespace); @@ -55,7 +57,7 @@ bool ICodeFile.AttachTypesSynchronously(GenerationRules rules, Assembly assembly { return false; } - + Debug.WriteLine(_generatedType?.SourceCode); return true; @@ -80,7 +82,12 @@ internal IEnumerable DetermineFrames(GenerationRules rules) { Postprocessors.Add(new WriteEmptyBodyStatusCode()); } - + + if (AuditedMembers.Any()) + { + Middleware.Insert(0, new AuditToActivityFrame(this)); + } + var index = 0; foreach (var frame in Middleware) { @@ -89,12 +96,12 @@ internal IEnumerable DetermineFrames(GenerationRules rules) { RouteParameterStrategy.TryApplyRouteVariables(this, call); } - + foreach (var result in frame.Creates.Where(x => x.VariableType.CanBeCastTo())) { result.OverrideName("result" + ++index); } - + yield return frame; } @@ -110,7 +117,7 @@ internal IEnumerable DetermineFrames(GenerationRules rules) private string determineFileName() { var parts = RoutePattern.RawText.Replace("{", "").Replace("*", "").Replace("}", "").Split('/').Select(x => x.Split(':').First()); - + return _httpMethods.Select(x => x.ToUpper()).Concat(parts).Join("_").Replace("-", "_").Replace("__", "_"); } } \ No newline at end of file diff --git a/src/Http/Wolverine.Http/HttpChain.cs b/src/Http/Wolverine.Http/HttpChain.cs index 70b9554d1..230c34b1f 100644 --- a/src/Http/Wolverine.Http/HttpChain.cs +++ b/src/Http/Wolverine.Http/HttpChain.cs @@ -53,7 +53,8 @@ public static bool IsValidResponseType(Type type) private GeneratedType? _generatedType; private Type? _handlerType; private string _description; - + private Type? _requestType; + public HttpChain(MethodCall method, HttpGraph parent) { _description = method.ToString(); @@ -93,7 +94,7 @@ public HttpChain(MethodCall method, HttpGraph parent) applyMetadata(); } - + private bool tryFindResourceType(MethodCall method, out Type resourceType) { resourceType = typeof(void); @@ -151,17 +152,28 @@ internal void MapToRoute(string method, string url, int? order = null, string? d public RoutePattern? RoutePattern { get; private set; } - public Type? RequestType { get; internal set; } + public Type? RequestType + { + get => _requestType; + internal set + { + _requestType = value; + if (_requestType != null) + { + applyAuditAttributes(_requestType); + } + } + } public override string Description => _description; internal RouteEndpoint? Endpoint { get; private set; } - + /// /// Required TenancyMode for this http chain /// public TenancyMode? TenancyMode { get; set; } - + public static HttpChain ChainFor(Expression> expression, HttpGraph? parent = null) { @@ -230,7 +242,7 @@ private void applyMetadata() Metadata.WithMetadata(new FromRouteMetadata(parameter.Name)); } } - + Metadata .WithMetadata(this) .WithMetadata(new WolverineMarker()) @@ -252,7 +264,7 @@ private void applyMetadata() { Metadata.Produces(200); } - + foreach (var attribute in Method.HandlerType.GetCustomAttributes()) Metadata.WithMetadata(attribute); foreach (var attribute in Method.Method.GetCustomAttributes()) Metadata.WithMetadata(attribute); } @@ -267,7 +279,7 @@ public bool FindRouteVariable(ParameterInfo parameter, out Variable variable) variable = existing; return true; } - + var matches = RoutePattern!.Parameters.Any(x => x.Name == parameter.Name); if (matches) { @@ -299,7 +311,7 @@ public bool FindRouteVariable(Type variableType, string routeOrParameterName, ou variable = matched; return true; } - + var matches = RoutePattern!.Parameters.Any(x => x.Name == routeOrParameterName); if (matches) { diff --git a/src/Http/WolverineWebApi/AuditableEndpoint.cs b/src/Http/WolverineWebApi/AuditableEndpoint.cs new file mode 100644 index 000000000..cc217ec46 --- /dev/null +++ b/src/Http/WolverineWebApi/AuditableEndpoint.cs @@ -0,0 +1,25 @@ +using Wolverine.Attributes; +using Wolverine.Http; + +namespace WolverineWebApi; + +public class AuditableEndpoint +{ + + [WolverinePost("/auditable/post"), EmptyResponse] + public string Post(AuditablePostBody body) + { + return "Hello"; + } + + [WolverinePost("/auditable/empty"), EmptyResponse] + public void EmptyPost(AuditablePostBody command) + { + } +} + +public class AuditablePostBody +{ + [Audit] + public Guid Id { get; set; } +} diff --git a/src/Http/WolverineWebApi/Internal/Generated/DocumentStorage/InvoiceProvider1936131227.cs b/src/Http/WolverineWebApi/Internal/Generated/DocumentStorage/InvoiceProvider1936131227.cs new file mode 100644 index 000000000..08bb09725 --- /dev/null +++ b/src/Http/WolverineWebApi/Internal/Generated/DocumentStorage/InvoiceProvider1936131227.cs @@ -0,0 +1,848 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System; +using System.Collections.Generic; +using Weasel.Core; +using Weasel.Postgresql; +using WolverineWebApi.Marten; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoiceOperation1936131227 + public class UpsertInvoiceOperation1936131227 : Marten.Internal.Operations.StorageOperation + { + private readonly WolverineWebApi.Marten.Invoice _document; + private readonly System.Guid _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoiceOperation1936131227(WolverineWebApi.Marten.Invoice document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + public const string COMMAND_TEXT = "select http.mt_upsert_invoice(?, ?, ?, ?)"; + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override string CommandText() + { + return COMMAND_TEXT; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Npgsql.NpgsqlParameter[] parameters, WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session) + { + parameters[0].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + parameters[0].Value = session.Serializer.ToJson(_document); + // .Net Class Type + parameters[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + parameters[1].Value = _document.GetType().FullName; + parameters[2].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + parameters[2].Value = document.Id; + setVersionParameter(parameters[3]); + } + + } + + // END: UpsertInvoiceOperation1936131227 + + + // START: InsertInvoiceOperation1936131227 + public class InsertInvoiceOperation1936131227 : Marten.Internal.Operations.StorageOperation + { + private readonly WolverineWebApi.Marten.Invoice _document; + private readonly System.Guid _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoiceOperation1936131227(WolverineWebApi.Marten.Invoice document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + public const string COMMAND_TEXT = "select http.mt_insert_invoice(?, ?, ?, ?)"; + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override string CommandText() + { + return COMMAND_TEXT; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Npgsql.NpgsqlParameter[] parameters, WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session) + { + parameters[0].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + parameters[0].Value = session.Serializer.ToJson(_document); + // .Net Class Type + parameters[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + parameters[1].Value = _document.GetType().FullName; + parameters[2].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + parameters[2].Value = document.Id; + setVersionParameter(parameters[3]); + } + + } + + // END: InsertInvoiceOperation1936131227 + + + // START: UpdateInvoiceOperation1936131227 + public class UpdateInvoiceOperation1936131227 : Marten.Internal.Operations.StorageOperation + { + private readonly WolverineWebApi.Marten.Invoice _document; + private readonly System.Guid _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoiceOperation1936131227(WolverineWebApi.Marten.Invoice document, System.Guid id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + public const string COMMAND_TEXT = "select http.mt_update_invoice(?, ?, ?, ?)"; + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override string CommandText() + { + return COMMAND_TEXT; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Npgsql.NpgsqlParameter[] parameters, WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session) + { + parameters[0].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + parameters[0].Value = session.Serializer.ToJson(_document); + // .Net Class Type + parameters[1].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + parameters[1].Value = _document.GetType().FullName; + parameters[2].NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + parameters[2].Value = document.Id; + setVersionParameter(parameters[3]); + } + + } + + // END: UpdateInvoiceOperation1936131227 + + + // START: QueryOnlyInvoiceSelector1936131227 + public class QueryOnlyInvoiceSelector1936131227 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoiceSelector1936131227(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public WolverineWebApi.Marten.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + + WolverineWebApi.Marten.Invoice document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + WolverineWebApi.Marten.Invoice document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoiceSelector1936131227 + + + // START: LightweightInvoiceSelector1936131227 + public class LightweightInvoiceSelector1936131227 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoiceSelector1936131227(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public WolverineWebApi.Marten.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = reader.GetFieldValue(0); + + WolverineWebApi.Marten.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = await reader.GetFieldValueAsync(0, token); + + WolverineWebApi.Marten.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoiceSelector1936131227 + + + // START: IdentityMapInvoiceSelector1936131227 + public class IdentityMapInvoiceSelector1936131227 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoiceSelector1936131227(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public WolverineWebApi.Marten.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = reader.GetFieldValue(0); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + WolverineWebApi.Marten.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = await reader.GetFieldValueAsync(0, token); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + WolverineWebApi.Marten.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoiceSelector1936131227 + + + // START: DirtyTrackingInvoiceSelector1936131227 + public class DirtyTrackingInvoiceSelector1936131227 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoiceSelector1936131227(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public WolverineWebApi.Marten.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = reader.GetFieldValue(0); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + WolverineWebApi.Marten.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = await reader.GetFieldValueAsync(0, token); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + WolverineWebApi.Marten.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoiceSelector1936131227 + + + // START: QueryOnlyInvoiceDocumentStorage1936131227 + public class QueryOnlyInvoiceDocumentStorage1936131227 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoiceDocumentStorage1936131227(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override System.Guid AssignIdentity(WolverineWebApi.Marten.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == Guid.Empty) _setter(document, Marten.Schema.Identity.CombGuidIdGeneration.NewGuid()); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override System.Guid Identity(WolverineWebApi.Marten.Invoice document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoiceSelector1936131227(session, _document); + } + + + public override Npgsql.NpgsqlCommand BuildLoadCommand(System.Guid id, string tenant) + { + return new NpgsqlCommand(_loaderSql).With("id", id); + } + + + public override Npgsql.NpgsqlCommand BuildLoadManyCommand(System.Guid[] ids, string tenant) + { + return new NpgsqlCommand(_loadArraySql).With("ids", ids); + } + + } + + // END: QueryOnlyInvoiceDocumentStorage1936131227 + + + // START: LightweightInvoiceDocumentStorage1936131227 + public class LightweightInvoiceDocumentStorage1936131227 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoiceDocumentStorage1936131227(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override System.Guid AssignIdentity(WolverineWebApi.Marten.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == Guid.Empty) _setter(document, Marten.Schema.Identity.CombGuidIdGeneration.NewGuid()); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override System.Guid Identity(WolverineWebApi.Marten.Invoice document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoiceSelector1936131227(session, _document); + } + + + public override Npgsql.NpgsqlCommand BuildLoadCommand(System.Guid id, string tenant) + { + return new NpgsqlCommand(_loaderSql).With("id", id); + } + + + public override Npgsql.NpgsqlCommand BuildLoadManyCommand(System.Guid[] ids, string tenant) + { + return new NpgsqlCommand(_loadArraySql).With("ids", ids); + } + + } + + // END: LightweightInvoiceDocumentStorage1936131227 + + + // START: IdentityMapInvoiceDocumentStorage1936131227 + public class IdentityMapInvoiceDocumentStorage1936131227 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoiceDocumentStorage1936131227(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override System.Guid AssignIdentity(WolverineWebApi.Marten.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == Guid.Empty) _setter(document, Marten.Schema.Identity.CombGuidIdGeneration.NewGuid()); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override System.Guid Identity(WolverineWebApi.Marten.Invoice document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoiceSelector1936131227(session, _document); + } + + + public override Npgsql.NpgsqlCommand BuildLoadCommand(System.Guid id, string tenant) + { + return new NpgsqlCommand(_loaderSql).With("id", id); + } + + + public override Npgsql.NpgsqlCommand BuildLoadManyCommand(System.Guid[] ids, string tenant) + { + return new NpgsqlCommand(_loadArraySql).With("ids", ids); + } + + } + + // END: IdentityMapInvoiceDocumentStorage1936131227 + + + // START: DirtyTrackingInvoiceDocumentStorage1936131227 + public class DirtyTrackingInvoiceDocumentStorage1936131227 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoiceDocumentStorage1936131227(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override System.Guid AssignIdentity(WolverineWebApi.Marten.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == Guid.Empty) _setter(document, Marten.Schema.Identity.CombGuidIdGeneration.NewGuid()); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1936131227 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(WolverineWebApi.Marten.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override System.Guid Identity(WolverineWebApi.Marten.Invoice document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoiceSelector1936131227(session, _document); + } + + + public override Npgsql.NpgsqlCommand BuildLoadCommand(System.Guid id, string tenant) + { + return new NpgsqlCommand(_loaderSql).With("id", id); + } + + + public override Npgsql.NpgsqlCommand BuildLoadManyCommand(System.Guid[] ids, string tenant) + { + return new NpgsqlCommand(_loadArraySql).With("ids", ids); + } + + } + + // END: DirtyTrackingInvoiceDocumentStorage1936131227 + + + // START: InvoiceBulkLoader1936131227 + public class InvoiceBulkLoader1936131227 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public InvoiceBulkLoader1936131227(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY http.mt_doc_invoice(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into http.mt_doc_invoice (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice_temp.\"id\", mt_doc_invoice_temp.\"data\", mt_doc_invoice_temp.\"mt_version\", mt_doc_invoice_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice_temp left join http.mt_doc_invoice on mt_doc_invoice_temp.id = http.mt_doc_invoice.id where http.mt_doc_invoice.id is null)"; + + public const string OVERWRITE_SQL = "update http.mt_doc_invoice target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice_temp as select * from http.mt_doc_invoice limit 0"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, WolverineWebApi.Marten.Invoice document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, WolverineWebApi.Marten.Invoice document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: InvoiceBulkLoader1936131227 + + + // START: InvoiceProvider1936131227 + public class InvoiceProvider1936131227 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public InvoiceProvider1936131227(Marten.Schema.DocumentMapping mapping) : base(new InvoiceBulkLoader1936131227(new QueryOnlyInvoiceDocumentStorage1936131227(mapping)), new QueryOnlyInvoiceDocumentStorage1936131227(mapping), new LightweightInvoiceDocumentStorage1936131227(mapping), new IdentityMapInvoiceDocumentStorage1936131227(mapping), new DirtyTrackingInvoiceDocumentStorage1936131227(mapping)) + { + _mapping = mapping; + } + + + } + + // END: InvoiceProvider1936131227 + + +} + diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/BookReservationHandler1573485708.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/BookReservationHandler1573485708.cs index 68b9da5b8..2be229e2c 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/BookReservationHandler1573485708.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/BookReservationHandler1573485708.cs @@ -8,13 +8,13 @@ namespace Internal.Generated.WolverineHandlers // START: BookReservationHandler1573485708 public class BookReservationHandler1573485708 : Wolverine.Runtime.Handlers.MessageHandler { - private readonly Microsoft.Extensions.Logging.ILogger _logger; private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + private readonly Microsoft.Extensions.Logging.ILogger _logger; - public BookReservationHandler1573485708(Microsoft.Extensions.Logging.ILogger logger, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + public BookReservationHandler1573485708(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Microsoft.Extensions.Logging.ILogger logger) { - _logger = logger; _outboxedSessionFactory = outboxedSessionFactory; + _logger = logger; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_data_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_data_id.cs index 6933055a9..03be4a700 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_data_id.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_data_id.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class GET_data_id : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public GET_data_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public GET_data_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_invoices_longhand_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_invoices_longhand_id.cs new file mode 100644 index 000000000..9b6b6a232 --- /dev/null +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_invoices_longhand_id.cs @@ -0,0 +1,48 @@ +// +#pragma warning disable +using Microsoft.AspNetCore.Routing; +using System; +using System.Linq; +using Wolverine.Http; +using Wolverine.Marten.Publishing; +using Wolverine.Runtime; + +namespace Internal.Generated.WolverineHandlers +{ + // START: GET_invoices_longhand_id + public class GET_invoices_longhand_id : Wolverine.Http.HttpHandler + { + private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; + private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + + public GET_invoices_longhand_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) + { + _wolverineHttpOptions = wolverineHttpOptions; + _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; + } + + + + public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) + { + var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); + // Building the Marten session + await using var querySession = _outboxedSessionFactory.QuerySession(messageContext); + System.Guid id = default; + System.Guid.TryParse(httpContext.Request.Query["id"], System.Globalization.CultureInfo.InvariantCulture, out id); + + // The actual HTTP request handler execution + var result = await WolverineWebApi.Marten.InvoicesEndpoint.GetInvoice(id, querySession, httpContext.RequestAborted).ConfigureAwait(false); + + await result.ExecuteAsync(httpContext).ConfigureAwait(false); + } + + } + + // END: GET_invoices_longhand_id + + +} + diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_swagger_users_userId.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_swagger_users_userId.cs index 4ad2a3ac2..85d2c5cb3 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_swagger_users_userId.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_swagger_users_userId.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class GET_swagger_users_userId : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public GET_swagger_users_userId(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public GET_swagger_users_userId(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_timed.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_timed.cs index 083914b5c..4ac4277f6 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_timed.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_timed.cs @@ -24,8 +24,8 @@ public GET_timed(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Micro public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { - var measuredEndpoint = new WolverineWebApi.MeasuredEndpoint(); var stopwatchMiddleware = new WolverineWebApi.StopwatchMiddleware(); + var measuredEndpoint = new WolverineWebApi.MeasuredEndpoint(); stopwatchMiddleware.Before(); // The actual HTTP request handler execution diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_write_to_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_write_to_id.cs index e6e8872ec..01df1d3c7 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_write_to_id.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_write_to_id.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class GET_write_to_id : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public GET_write_to_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public GET_write_to_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_empty.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_empty.cs new file mode 100644 index 000000000..68dcd1e25 --- /dev/null +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_empty.cs @@ -0,0 +1,44 @@ +// +#pragma warning disable +using Microsoft.AspNetCore.Routing; +using System; +using System.Linq; +using Wolverine.Http; + +namespace Internal.Generated.WolverineHandlers +{ + // START: POST_auditable_empty + public class POST_auditable_empty : Wolverine.Http.HttpHandler + { + private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; + + public POST_auditable_empty(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions) : base(wolverineHttpOptions) + { + _wolverineHttpOptions = wolverineHttpOptions; + } + + + + public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) + { + var auditableEndpoint = new WolverineWebApi.AuditableEndpoint(); + // Reading the request body via JSON deserialization + var (command, jsonContinue) = await ReadJsonAsync(httpContext); + if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; + // Application-specific Open Telemetry auditing + System.Diagnostics.Activity.Current?.SetTag("id", command.Id); + + // The actual HTTP request handler execution + auditableEndpoint.EmptyPost(command); + + // Wolverine automatically sets the status code to 204 for empty responses + if (!httpContext.Response.HasStarted) httpContext.Response.StatusCode = 204; + } + + } + + // END: POST_auditable_empty + + +} + diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_post.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_post.cs new file mode 100644 index 000000000..ac8a9d185 --- /dev/null +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_auditable_post.cs @@ -0,0 +1,52 @@ +// +#pragma warning disable +using Microsoft.AspNetCore.Routing; +using System; +using System.Linq; +using Wolverine.Http; +using Wolverine.Runtime; + +namespace Internal.Generated.WolverineHandlers +{ + // START: POST_auditable_post + public class POST_auditable_post : Wolverine.Http.HttpHandler + { + private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; + private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + + public POST_auditable_post(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + { + _wolverineHttpOptions = wolverineHttpOptions; + _wolverineRuntime = wolverineRuntime; + } + + + + public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) + { + var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); + var auditableEndpoint = new WolverineWebApi.AuditableEndpoint(); + // Reading the request body via JSON deserialization + var (body, jsonContinue) = await ReadJsonAsync(httpContext); + if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; + // Application-specific Open Telemetry auditing + System.Diagnostics.Activity.Current?.SetTag("id", body.Id); + + // The actual HTTP request handler execution + var result_of_Post = auditableEndpoint.Post(body); + + + // Outgoing, cascaded message + await messageContext.EnqueueCascadingAsync(result_of_Post).ConfigureAwait(false); + + // Wolverine automatically sets the status code to 204 for empty responses + if (!httpContext.Response.HasStarted) httpContext.Response.StatusCode = 204; + } + + } + + // END: POST_auditable_post + + +} + diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_create.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_create.cs index f5204bbbd..6876d8b33 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_create.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_create.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_ef_create : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Microsoft.EntityFrameworkCore.DbContextOptions _dbContextOptions; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Microsoft.EntityFrameworkCore.DbContextOptions _dbContextOptions; - public POST_ef_create(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Microsoft.EntityFrameworkCore.DbContextOptions dbContextOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_ef_create(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Microsoft.EntityFrameworkCore.DbContextOptions dbContextOptions) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _dbContextOptions = dbContextOptions; _wolverineRuntime = wolverineRuntime; + _dbContextOptions = dbContextOptions; } @@ -28,8 +28,8 @@ public POST_ef_create(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { var efCoreEndpoints = new WolverineWebApi.EfCoreEndpoints(); - await using var itemsDbContext = new WolverineWebApi.ItemsDbContext(_dbContextOptions); var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); + await using var itemsDbContext = new WolverineWebApi.ItemsDbContext(_dbContextOptions); // Enroll the DbContext & IMessagingContext in the outgoing Wolverine outbox transaction var envelopeTransaction = Wolverine.EntityFrameworkCore.WolverineEntityCoreExtensions.BuildTransaction(itemsDbContext, messageContext); diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_publish.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_publish.cs index 79b05eab2..4f771375d 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_publish.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_ef_publish.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_ef_publish : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Microsoft.EntityFrameworkCore.DbContextOptions _dbContextOptions; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Microsoft.EntityFrameworkCore.DbContextOptions _dbContextOptions; - public POST_ef_publish(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Microsoft.EntityFrameworkCore.DbContextOptions dbContextOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_ef_publish(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Microsoft.EntityFrameworkCore.DbContextOptions dbContextOptions) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _dbContextOptions = dbContextOptions; _wolverineRuntime = wolverineRuntime; + _dbContextOptions = dbContextOptions; } @@ -28,8 +28,8 @@ public POST_ef_publish(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { var efCoreEndpoints = new WolverineWebApi.EfCoreEndpoints(); - var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); await using var itemsDbContext = new WolverineWebApi.ItemsDbContext(_dbContextOptions); + var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); Wolverine.Http.Runtime.RequestIdMiddleware.Apply(httpContext, messageContext); // Enroll the DbContext & IMessagingContext in the outgoing Wolverine outbox transaction diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_invoices_number_approve.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_invoices_number_approve.cs index 26a761b10..d8173ca39 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_invoices_number_approve.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_invoices_number_approve.cs @@ -27,9 +27,6 @@ public POST_invoices_number_approve(Wolverine.Http.WolverineHttpOptions wolverin public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { - var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); - // Building the Marten session - await using var documentSession = _outboxedSessionFactory.OpenSession(messageContext); if (!System.Guid.TryParse((string)httpContext.GetRouteValue("number"), out var number)) { httpContext.Response.StatusCode = 404; @@ -37,6 +34,9 @@ public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Ht } + var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); + // Building the Marten session + await using var documentSession = _outboxedSessionFactory.OpenSession(messageContext); var invoice = await documentSession.LoadAsync(number, httpContext.RequestAborted).ConfigureAwait(false); // The actual HTTP request handler execution diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_issue.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_issue.cs index d5decea66..bb77f1f86 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_issue.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_issue.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_issue : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_issue(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_issue(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create.cs index f725513e4..5596555a8 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_create : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_create(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_create(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create2.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create2.cs index 4e61655d1..11915b832 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create2.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create2.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_create2 : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_create2(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_create2(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create3.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create3.cs index c972e315a..eed22f4c8 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create3.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create3.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_create3 : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_create3(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_create3(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create4.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create4.cs index ff7fa6a6e..a8211aaf3 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create4.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_create4.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_create4 : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_create4(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_create4(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_itemready.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_itemready.cs index f483f8640..fa79d0b2c 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_itemready.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_itemready.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_itemready : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_itemready(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_itemready(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_orderId_ship4.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_orderId_ship4.cs index fa2e10c2d..fc718ef29 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_orderId_ship4.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_orderId_ship4.cs @@ -27,7 +27,6 @@ public POST_orders_orderId_ship4(Wolverine.Http.WolverineHttpOptions wolverineHt public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { - var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); if (!System.Guid.TryParse((string)httpContext.GetRouteValue("orderId"), out var orderId)) { httpContext.Response.StatusCode = 404; @@ -35,6 +34,7 @@ public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Ht } + var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); await using var documentSession = _outboxedSessionFactory.OpenSession(messageContext); var eventStore = documentSession.Events; diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_ship.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_ship.cs index 866e73d5a..6c8361dd8 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_ship.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_ship.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_orders_ship : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_orders_ship(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_orders_ship(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_publish_marten_message.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_publish_marten_message.cs index e760880f7..e34c31837 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_publish_marten_message.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_publish_marten_message.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_publish_marten_message : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_publish_marten_message(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_publish_marten_message(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation.cs index b05c512f7..22ff1cbbd 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_reservation : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_reservation(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_reservation(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation2.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation2.cs index 6c7f2e2e5..c0f612daf 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation2.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_reservation2.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_reservation2 : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_reservation2(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_reservation2(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_some_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_some_id.cs index b9dee09f2..ef85a159c 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_some_id.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_some_id.cs @@ -27,10 +27,10 @@ public POST_some_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wo public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { + var id = (string)httpContext.GetRouteValue("id"); var messageContext = new Wolverine.Runtime.MessageContext(_wolverineRuntime); // Building the Marten session await using var documentSession = _outboxedSessionFactory.OpenSession(messageContext); - var id = (string)httpContext.GetRouteValue("id"); // Reading the request body via JSON deserialization var (request, jsonContinue) = await ReadJsonAsync(httpContext); if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_swagger_empty.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_swagger_empty.cs index c5d593201..26b911111 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_swagger_empty.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_swagger_empty.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_swagger_empty : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_swagger_empty(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_swagger_empty(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_todoitems.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_todoitems.cs index 2974d2aa9..332f30ef9 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_todoitems.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_todoitems.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_todoitems : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public POST_todoitems(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public POST_todoitems(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate2_user.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate2_user.cs index afa92900f..3a2180555 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate2_user.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate2_user.cs @@ -13,23 +13,23 @@ namespace Internal.Generated.WolverineHandlers public class POST_validate2_user : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly FluentValidation.IValidator _validator_of_CreateUser2_63356719; + private readonly FluentValidation.IValidator _validator_of_CreateUser2_348930900; + private readonly FluentValidation.IValidator _validator_of_CreateUser2_1683673752; private readonly Wolverine.Http.FluentValidation.IProblemDetailSource _problemDetailSource; - private readonly FluentValidation.IValidator _validator_of_CreateUser21377740867; - public POST_validate2_user(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, [Lamar.Named("createUserValidator")] FluentValidation.IValidator validator_of_CreateUser2_63356719, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource, [Lamar.Named("passwordValidator")] FluentValidation.IValidator validator_of_CreateUser21377740867) : base(wolverineHttpOptions) + public POST_validate2_user(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, [Lamar.Named("createUserValidator")] FluentValidation.IValidator validator_of_CreateUser2_348930900, [Lamar.Named("passwordValidator")] FluentValidation.IValidator validator_of_CreateUser2_1683673752, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _validator_of_CreateUser2_63356719 = validator_of_CreateUser2_63356719; + _validator_of_CreateUser2_348930900 = validator_of_CreateUser2_348930900; + _validator_of_CreateUser2_1683673752 = validator_of_CreateUser2_1683673752; _problemDetailSource = problemDetailSource; - _validator_of_CreateUser21377740867 = validator_of_CreateUser21377740867; } public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { - var validatorList = new System.Collections.Generic.List>{_validator_of_CreateUser2_63356719, _validator_of_CreateUser21377740867}; + var validatorList = new System.Collections.Generic.List>{_validator_of_CreateUser2_348930900, _validator_of_CreateUser2_1683673752}; // Reading the request body via JSON deserialization var (user, jsonContinue) = await ReadJsonAsync(httpContext); if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_customer.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_customer.cs index 52e75a8e7..8b611eb38 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_customer.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_customer.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class POST_validate_customer : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Http.FluentValidation.IProblemDetailSource _problemDetailSource; private readonly FluentValidation.IValidator _validator; + private readonly Wolverine.Http.FluentValidation.IProblemDetailSource _problemDetailSource; - public POST_validate_customer(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource, FluentValidation.IValidator validator) : base(wolverineHttpOptions) + public POST_validate_customer(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, FluentValidation.IValidator validator, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _problemDetailSource = problemDetailSource; _validator = validator; + _problemDetailSource = problemDetailSource; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_user.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_user.cs index 4bb15b2c5..5b2d78850 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_user.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_validate_user.cs @@ -13,23 +13,23 @@ namespace Internal.Generated.WolverineHandlers public class POST_validate_user : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly FluentValidation.IValidator _validator_of_CreateUser_1682536441; - private readonly FluentValidation.IValidator _validator_of_CreateUser898719893; + private readonly FluentValidation.IValidator _validator_of_CreateUser1376587052; private readonly Wolverine.Http.FluentValidation.IProblemDetailSource _problemDetailSource; + private readonly FluentValidation.IValidator _validator_of_CreateUser580623592; - public POST_validate_user(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, [Lamar.Named("passwordValidator")] FluentValidation.IValidator validator_of_CreateUser_1682536441, [Lamar.Named("createUserValidator")] FluentValidation.IValidator validator_of_CreateUser898719893, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource) : base(wolverineHttpOptions) + public POST_validate_user(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, [Lamar.Named("passwordValidator")] FluentValidation.IValidator validator_of_CreateUser1376587052, Wolverine.Http.FluentValidation.IProblemDetailSource problemDetailSource, [Lamar.Named("createUserValidator")] FluentValidation.IValidator validator_of_CreateUser580623592) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _validator_of_CreateUser_1682536441 = validator_of_CreateUser_1682536441; - _validator_of_CreateUser898719893 = validator_of_CreateUser898719893; + _validator_of_CreateUser1376587052 = validator_of_CreateUser1376587052; _problemDetailSource = problemDetailSource; + _validator_of_CreateUser580623592 = validator_of_CreateUser580623592; } public override async System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpContext httpContext) { - var validatorList = new System.Collections.Generic.List>{_validator_of_CreateUser898719893, _validator_of_CreateUser_1682536441}; + var validatorList = new System.Collections.Generic.List>{_validator_of_CreateUser580623592, _validator_of_CreateUser1376587052}; // Reading the request body via JSON deserialization var (user, jsonContinue) = await ReadJsonAsync(httpContext); if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos2_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos2_id.cs index d1b957754..e661a2c52 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos2_id.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos2_id.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class PUT_todos2_id : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public PUT_todos2_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public PUT_todos2_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos_id.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos_id.cs index 8bdb92a2a..2cfe3ace7 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos_id.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/PUT_todos_id.cs @@ -13,14 +13,14 @@ namespace Internal.Generated.WolverineHandlers public class PUT_todos_id : Wolverine.Http.HttpHandler { private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; - private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; + private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; - public PUT_todos_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Wolverine.Runtime.IWolverineRuntime wolverineRuntime) : base(wolverineHttpOptions) + public PUT_todos_id(Wolverine.Http.WolverineHttpOptions wolverineHttpOptions, Wolverine.Runtime.IWolverineRuntime wolverineRuntime, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) : base(wolverineHttpOptions) { _wolverineHttpOptions = wolverineHttpOptions; - _outboxedSessionFactory = outboxedSessionFactory; _wolverineRuntime = wolverineRuntime; + _outboxedSessionFactory = outboxedSessionFactory; } diff --git a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/ReservationTimeoutHandler457905910.cs b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/ReservationTimeoutHandler457905910.cs index b57203531..1984a7a7b 100644 --- a/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/ReservationTimeoutHandler457905910.cs +++ b/src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/ReservationTimeoutHandler457905910.cs @@ -8,13 +8,13 @@ namespace Internal.Generated.WolverineHandlers // START: ReservationTimeoutHandler457905910 public class ReservationTimeoutHandler457905910 : Wolverine.Runtime.Handlers.MessageHandler { - private readonly Microsoft.Extensions.Logging.ILogger _logger; private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; + private readonly Microsoft.Extensions.Logging.ILogger _logger; - public ReservationTimeoutHandler457905910(Microsoft.Extensions.Logging.ILogger logger, Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory) + public ReservationTimeoutHandler457905910(Wolverine.Marten.Publishing.OutboxedSessionFactory outboxedSessionFactory, Microsoft.Extensions.Logging.ILogger logger) { - _logger = logger; _outboxedSessionFactory = outboxedSessionFactory; + _logger = logger; } diff --git a/src/Wolverine/Configuration/Chain.cs b/src/Wolverine/Configuration/Chain.cs index c5d8847bb..8986b3be3 100644 --- a/src/Wolverine/Configuration/Chain.cs +++ b/src/Wolverine/Configuration/Chain.cs @@ -87,6 +87,25 @@ private bool isConfigureMethod(MethodInfo method) } + protected void applyAuditAttributes(Type type) + { + foreach (var property in type.GetProperties()) + { + if (property.TryGetAttribute(out var ratt)) + { + Audit(property, ratt.Heading); + } + } + + foreach (var field in type.GetFields()) + { + if (field.TryGetAttribute(out var ratt)) + { + Audit(field, ratt.Heading); + } + } + } + protected void applyAttributesAndConfigureMethods(GenerationRules rules, IContainer container) { var handlers = HandlerCalls(); diff --git a/src/Wolverine/Logging/AuditToActivityFrame.cs b/src/Wolverine/Logging/AuditToActivityFrame.cs index 8f419f791..fafa3d06a 100644 --- a/src/Wolverine/Logging/AuditToActivityFrame.cs +++ b/src/Wolverine/Logging/AuditToActivityFrame.cs @@ -7,7 +7,7 @@ namespace Wolverine.Logging; -internal class AuditToActivityFrame : SyncFrame +public class AuditToActivityFrame : SyncFrame { private readonly Type _inputType; private readonly List _members; diff --git a/src/Wolverine/Runtime/Handlers/HandlerChain.cs b/src/Wolverine/Runtime/Handlers/HandlerChain.cs index 7e49f7417..6e8b28dc9 100644 --- a/src/Wolverine/Runtime/Handlers/HandlerChain.cs +++ b/src/Wolverine/Runtime/Handlers/HandlerChain.cs @@ -53,21 +53,7 @@ public HandlerChain(Type messageType, HandlerGraph parent) Description = "Message Handler for " + MessageType.FullNameInCode(); - foreach (var property in messageType.GetProperties()) - { - if (property.TryGetAttribute(out var att)) - { - Audit(property, att.Heading); - } - } - - foreach (var field in messageType.GetFields()) - { - if (field.TryGetAttribute(out var att)) - { - Audit(field, att.Heading); - } - } + applyAuditAttributes(messageType); }