-
-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added AcceptResponse
to allow automated mapping of the 202 status with the Location Header
#726
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 1 addition & 4 deletions
5
src/Http/Wolverine.Http/Resources/WolverineProducesResponseTypeMetadata.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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Http.Metadata; | ||
|
||
namespace Wolverine.Http.Resources; | ||
|
||
internal class WolverineProducesResponseTypeMetadata : IProducesResponseTypeMetadata | ||
public class WolverineProducesResponseTypeMetadata : IProducesResponseTypeMetadata | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. COMMENT: Without that one wouldn't be able to create its own |
||
public Type? Type { get; init; } | ||
public int StatusCode { get; init; } | ||
|
65 changes: 65 additions & 0 deletions
65
src/Http/WolverineWebApi/Internal/Generated/WolverineHandlers/POST_orders_id_confirm.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,65 @@ | ||
// <auto-generated/> | ||
#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: POST_orders_id_confirm | ||
public class POST_orders_id_confirm : Wolverine.Http.HttpHandler | ||
{ | ||
private readonly Wolverine.Http.WolverineHttpOptions _wolverineHttpOptions; | ||
private readonly Wolverine.Runtime.IWolverineRuntime _wolverineRuntime; | ||
private readonly Wolverine.Marten.Publishing.OutboxedSessionFactory _outboxedSessionFactory; | ||
|
||
public POST_orders_id_confirm(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); | ||
// Reading the request body via JSON deserialization | ||
var (command, jsonContinue) = await ReadJsonAsync<WolverineWebApi.Marten.ConfirmOrder>(httpContext); | ||
if (jsonContinue == Wolverine.HandlerContinuation.Stop) return; | ||
await using var documentSession = _outboxedSessionFactory.OpenSession(messageContext); | ||
var eventStore = documentSession.Events; | ||
|
||
// Loading Marten aggregate | ||
var eventStream = await eventStore.FetchForWriting<WolverineWebApi.Marten.Order>(command.OrderId, httpContext.RequestAborted).ConfigureAwait(false); | ||
|
||
|
||
// The actual HTTP request handler execution | ||
(var acceptResponse_response, var events) = WolverineWebApi.Marten.MarkItemEndpoint.Confirm(command, eventStream.Aggregate); | ||
|
||
if (events != null) | ||
{ | ||
|
||
// Capturing any possible events returned from the command handlers | ||
eventStream.AppendMany(events); | ||
|
||
} | ||
|
||
// This response type customizes the HTTP response | ||
ApplyHttpAware(acceptResponse_response, httpContext); | ||
await documentSession.SaveChangesAsync(httpContext.RequestAborted).ConfigureAwait(false); | ||
// Writing the response body to JSON because this was the first 'return variable' in the method signature | ||
await WriteJsonAsync(httpContext, acceptResponse_response); | ||
} | ||
|
||
} | ||
|
||
// END: POST_orders_id_confirm | ||
|
||
|
||
} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMMENT: Boy Scout rule 🫡