Skip to content

Commit

Permalink
Test proving that an HTTP handler should be able to infer an EmptyRes…
Browse files Browse the repository at this point in the history
…ponse if all the return values are IWolverineReturnType Closes GH-473
  • Loading branch information
jeremydmiller committed Jul 14, 2023
1 parent 8d7943b commit 242b2ba
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Http/Wolverine.Http/HttpChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ private bool tryFindResourceType(MethodCall method, out Type resourceType)
{
return false;
}



resourceType = method.Creates.First().VariableType;
return IsValidResponseType(resourceType);
Expand Down
1 change: 1 addition & 0 deletions src/Http/Wolverine.Http/Resources/EmptyBody204Policy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public bool TryApply(HttpChain chain)
if (chain.ResourceType == null || chain.ResourceType == typeof(void))
{
chain.Postprocessors.Insert(0, new WriteEmptyBodyStatusCode());
chain.Metadata.Produces(204);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/WolverineWebApi/Samples/TodoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static class UpdateEndpoint
public static Task<Todo?> LoadAsync(int id, IDocumentSession session)
=> session.LoadAsync<Todo>(id);

[WolverinePut("/todos/{id:int}"), EmptyResponse]
[WolverinePut("/todos/{id:int}")]
public static StoreDoc<Todo> Put(int id, UpdateRequest request, [Required] Todo? todo)
{
todo.Name = request.Name;
Expand Down
4 changes: 3 additions & 1 deletion src/Wolverine/ISendMyself.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Wolverine.Configuration;

namespace Wolverine;

/// <summary>
/// Interface for cascading messages that require some customization of how
/// the resulting inner message is sent out
/// </summary>
public interface ISendMyself
public interface ISendMyself : IWolverineReturnType
{
ValueTask ApplyAsync(IMessageContext context);
}
Expand Down

0 comments on commit 242b2ba

Please sign in to comment.