diff --git a/docs/guide/http/middleware.md b/docs/guide/http/middleware.md index 99ebe67f8..0d84678ab 100644 --- a/docs/guide/http/middleware.md +++ b/docs/guide/http/middleware.md @@ -150,7 +150,31 @@ public class StopwatchMiddleware And you want to apply it to a single HTTP endpoint without having to dirty your hands with an attribute. You can use that naming convention up above like so: -sample: sample_applying_middleware_programmatically_to_one_chain + + +```cs +public class MeasuredEndpoint +{ + // The signature is meaningful here + public static void Configure(HttpChain chain) + { + // Call this method before the normal endpoint + chain.Middleware.Add(MethodCall.For(x => x.Before())); + + // Call this method after the normal endpoint + chain.Postprocessors.Add(MethodCall.For(x => x.Finally(null, null))); + } + + [WolverineGet("/timed")] + public async Task Get() + { + await Task.Delay(100.Milliseconds()); + return "how long did I take?"; + } +} +``` +snippet source | anchor + ## Apply Middleware by Policy