diff --git a/docs/guide/http/endpoints.md b/docs/guide/http/endpoints.md index 856ec4f8d..d3f97f177 100644 --- a/docs/guide/http/endpoints.md +++ b/docs/guide/http/endpoints.md @@ -311,7 +311,7 @@ and register that strategy within our `MapWolverineEndpoints()` set up like so: // Customizing parameter handling opts.AddParameterHandlingStrategy(); ``` -snippet source | anchor +snippet source | anchor And lastly, here's the application within an HTTP endpoint for extra context: diff --git a/docs/guide/http/mediator.md b/docs/guide/http/mediator.md index 54c40da5d..7484602c4 100644 --- a/docs/guide/http/mediator.md +++ b/docs/guide/http/mediator.md @@ -43,7 +43,7 @@ app.MapPostToWolverine("/wolverine/request"); app.MapDeleteToWolverine("/wolverine/request"); app.MapPutToWolverine("/wolverine/request"); ``` -snippet source | anchor +snippet source | anchor With this mechanism, Wolverine is able to optimize the runtime function for Minimal API by eliminating IoC service locations diff --git a/docs/guide/http/middleware.md b/docs/guide/http/middleware.md index c28633073..3d7e76a88 100644 --- a/docs/guide/http/middleware.md +++ b/docs/guide/http/middleware.md @@ -41,6 +41,16 @@ public class FakeAuthenticationMiddleware snippet source | anchor +Which is registered like this (or as described in [`Registering Middleware by Message Type`](/guide/handlers/middleware.html##registering-middleware-by-message-type)): + + + +```cs +opts.AddMiddlewareByMessageType(typeof(FakeAuthenticationMiddleware)); +``` +snippet source | anchor + + The key point to notice there is that `IResult` is a "return value" of the middleware. In the case of an HTTP endpoint, Wolverine will check if that `IResult` is a `WolverineContinue` object, and if so, will continue processing. If the `IResult` object is anything else, Wolverine will execute that `IResult` and stop processing the HTTP request otherwise. diff --git a/src/Http/WolverineWebApi/Program.cs b/src/Http/WolverineWebApi/Program.cs index 107405065..60f575094 100644 --- a/src/Http/WolverineWebApi/Program.cs +++ b/src/Http/WolverineWebApi/Program.cs @@ -129,7 +129,9 @@ opts.AddMiddleware(typeof(BeforeAndAfterMiddleware), chain => chain.Method.HandlerType == typeof(MiddlewareEndpoints)); +#region sample_register_http_middleware_by_type opts.AddMiddlewareByMessageType(typeof(FakeAuthenticationMiddleware)); +#endregion // Publish messages coming from opts.PublishMessage(HttpMethod.Post, "/publish/message1");