-
-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using 204 as the status code when there's no resource. Closes GH-303
- Loading branch information
Jeremy D. Miller
authored and
Jeremy D. Miller
committed
Apr 19, 2023
1 parent
42c3361
commit 1f64c2a
Showing
36 changed files
with
118 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using JasperFx.CodeGeneration; | ||
using JasperFx.CodeGeneration.Frames; | ||
using JasperFx.CodeGeneration.Model; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Wolverine.Http.Resources; | ||
|
||
internal class EmptyBody204Policy : IResourceWriterPolicy | ||
{ | ||
public bool TryApply(HttpChain chain) | ||
{ | ||
if (chain.ResourceType == null || chain.ResourceType == typeof(void)) | ||
{ | ||
chain.Postprocessors.Insert(0, new WriteEmptyBodyStatusCode()); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
internal class WriteEmptyBodyStatusCode : SyncFrame | ||
{ | ||
private Variable? _context; | ||
|
||
public override void GenerateCode(GeneratedMethod method, ISourceWriter writer) | ||
{ | ||
writer.WriteComment("Wolverine automatically sets the status code to 204 for empty responses"); | ||
writer.Write($"{_context!.Usage}.{nameof(HttpContext.Response)}.{nameof(HttpResponse.StatusCode)} = 204;"); | ||
Next?.GenerateCode(method, writer); | ||
} | ||
|
||
public override IEnumerable<Variable> FindVariables(IMethodVariables chain) | ||
{ | ||
_context = chain.FindVariable(typeof(HttpContext)); | ||
yield return _context; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Http/Wolverine.Http/Resources/ProducesResponseTypeMetadata.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Microsoft.AspNetCore.Http.Metadata; | ||
|
||
namespace Wolverine.Http.Resources; | ||
|
||
internal class ProducesResponseTypeMetadata : IProducesResponseTypeMetadata | ||
{ | ||
public Type? Type { get; init; } | ||
public int StatusCode { get; init; } | ||
public IEnumerable<string> ContentTypes => new string[] { "application/json" }; | ||
} |
70 changes: 0 additions & 70 deletions
70
...lverineWebApi/Internal/Generated/WolverineHandlers/BookReservationHandler1573485708.cs.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_fake_hello.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/GET_fake_hello_async.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.