Skip to content

Commit

Permalink
fix to adding auditable members to HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Nov 9, 2023
1 parent 4025c82 commit 14b573e
Show file tree
Hide file tree
Showing 32 changed files with 1,000 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using JasperFx.CodeGeneration;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using Microsoft.AspNetCore.Http;
using Shouldly;
using WolverineWebApi;

Expand All @@ -18,12 +21,5 @@ public void finds_audit_members_from_attributes()
chain.AuditedMembers.Single()
.MemberName.ShouldBe(nameof(AuditablePostBody.Id));
}

[Fact]
public void adds_auditable_members_to_activity()
{
var chain = HttpChains.ChainFor("POST", "/auditable/post");
var lines = chain.SourceCode.ReadLines();
lines.Any(x => x.Contains("Activity.Current?.SetTag(\"id\", body.Id)")).ShouldBeTrue();
}

}
16 changes: 14 additions & 2 deletions src/Http/Wolverine.Http/HttpChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static bool IsValidResponseType(Type type)
private GeneratedType? _generatedType;
private Type? _handlerType;
private string _description;
private Type? _requestType;

public HttpChain(MethodCall method, HttpGraph parent)
{
Expand All @@ -73,7 +74,7 @@ public HttpChain(MethodCall method, HttpGraph parent)
NoContent = true;
ResourceType = typeof(void);
}

Metadata = new RouteHandlerBuilder(new[] { this });

if (method.Method.TryGetAttribute<WolverineHttpMethodAttribute>(out var att))
Expand Down Expand Up @@ -151,7 +152,18 @@ 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;

Expand Down
Loading

0 comments on commit 14b573e

Please sign in to comment.