diff --git a/docs/guide/http/endpoints.md b/docs/guide/http/endpoints.md index b53c5a3ee..4b4773b35 100644 --- a/docs/guide/http/endpoints.md +++ b/docs/guide/http/endpoints.md @@ -1,11 +1,5 @@ # HTTP Endpoints -::: warning -In all cases, the resource returned from a Wolverine HTTP endpoint method **is not automatically -published as a Wolverine cascaded message**. At this moment you will have to directly use `IMessageBus` -in your method signature to publish messages. -::: - First, a little terminology about Wolverine HTTP endpoints. Consider the following endpoint method: diff --git a/docs/guide/http/sagas.md b/docs/guide/http/sagas.md index 6ceb8eee7..fba6f727f 100644 --- a/docs/guide/http/sagas.md +++ b/docs/guide/http/sagas.md @@ -58,3 +58,10 @@ public static ( snippet source | anchor +Remember in Wolverine.HTTP that the *first* return value of an endpoint is assumed to be the response body by Wolverine, so if you are +wanting to start a new saga from an HTTP endpoint, the `Saga` return value either has to be a secondary value in a tuple to +opt into the Saga mechanics. Alternatively, if all you want to do is start a new saga, but nothing else, you can return +the `Saga` type *and* force Wolverine to use the return value as a new `Saga` like so: + +snippet: sample_start_saga_from_http_endpoint_empty_body + diff --git a/src/Http/Wolverine.Http/NotBodyAttribute.cs b/src/Http/Wolverine.Http/NotBodyAttribute.cs index 9c34ea94d..70eb76702 100644 --- a/src/Http/Wolverine.Http/NotBodyAttribute.cs +++ b/src/Http/Wolverine.Http/NotBodyAttribute.cs @@ -5,7 +5,7 @@ namespace Wolverine.Http; /// Wolverine that this parameter is *not* sourced from the /// HTTP request body /// -[AttributeUsage(AttributeTargets.Parameter)] +[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue)] public class NotBodyAttribute : Attribute { } \ No newline at end of file diff --git a/src/Http/WolverineWebApi/SagaExample.cs b/src/Http/WolverineWebApi/SagaExample.cs index 382c10cc2..01c30f779 100644 --- a/src/Http/WolverineWebApi/SagaExample.cs +++ b/src/Http/WolverineWebApi/SagaExample.cs @@ -30,6 +30,22 @@ public static ( } #endregion + + #region sample_start_saga_from_http_endpoint_empty_body + + [WolverinePost("/reservation2")] + + // This directs Wolverine to disregard the Reservation return value + // as the response body, and allow Wolverine to use the Reservation + // return as a new saga + [EmptyResponse] + public static Reservation Post2(StartReservation start) + { + return new Reservation { Id = start.ReservationId }; + } + + #endregion + } public record BookReservation(string Id);