Skip to content

Commit

Permalink
Reorder attribute application in HttpChain
Browse files Browse the repository at this point in the history
The attribute application code was moved below the Metadata and ResourceType definitions in HttpChain.cs. This modification ensures the Metadata and ResourceType are defined. chain.Metadata.Produces(..) calls within new Marten attributes will not longer break startup
  • Loading branch information
carcer authored and jeremydmiller committed Nov 7, 2023
1 parent 183399a commit df4550d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Http/Wolverine.Http/HttpChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ public HttpChain(MethodCall method, HttpGraph parent)

DisplayName = Method.ToString();

if (method.Method.TryGetAttribute<WolverineHttpMethodAttribute>(out var att))
{
MapToRoute(att.HttpMethod, att.Template, att.Order);
if (att.Name.IsNotEmpty())
{
DisplayName = att.Name;
}
}

if (tryFindResourceType(method, out var responseType))
{
NoContent = false;
Expand All @@ -82,8 +73,17 @@ public HttpChain(MethodCall method, HttpGraph parent)
NoContent = true;
ResourceType = typeof(void);
}

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

if (method.Method.TryGetAttribute<WolverineHttpMethodAttribute>(out var att))
{
MapToRoute(att.HttpMethod, att.Template, att.Order);
if (att.Name.IsNotEmpty())
{
DisplayName = att.Name;
}
}

// Apply attributes and the Configure() method if that exists too
applyAttributesAndConfigureMethods(_parent.Rules, _parent.Container);
Expand Down

0 comments on commit df4550d

Please sign in to comment.