From 85b337b035fa4d137c3b7f66ab5fb0753b726e36 Mon Sep 17 00:00:00 2001 From: Allan Ritchie Date: Sat, 9 Nov 2024 09:57:50 -0500 Subject: [PATCH] Update aspnet.mdx --- .../client/mediator/extensions/aspnet.mdx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/content/docs/client/mediator/extensions/aspnet.mdx b/src/content/docs/client/mediator/extensions/aspnet.mdx index 58f1045..75a85de 100644 --- a/src/content/docs/client/mediator/extensions/aspnet.mdx +++ b/src/content/docs/client/mediator/extensions/aspnet.mdx @@ -27,7 +27,7 @@ following; 1. Install Shiny.Mediator.AspNet to your ASP.NET Core project. -2. On your request handler (void or result based), add `[MediatorHttpPost("OperationId", "MyRoute")]` or `[MediatorHttpPut("OperationId", "MyRoute")]` attribute to the handler. +2. On your request handler (void or result based), add `[MediatorHttpPost("OperationId", "MyRoute")]` or `[MediatorHttpPut("OperationId", "MyRoute")]` (GET & DELETE attributes also available) attribute to the handler. ```csharp [MediatorHttpPost("TheOperationId", "MyRoute")] @@ -40,20 +40,19 @@ following; } ``` -3. In your host startup, register your handler (or use the source generator attributes). +3. In your host startup, add the following after your build your app. Here is a full-ish sample ```csharp - services.AddSingletonAsImplementedInterfaces(); - ``` + var builder = WebApplication.CreateBuilder(args); -4. Again, in your host startup, add the following after your build your app. Here is a full-ish sample + // MAKE MEDIATOR AVAILABLE + builder.Services.AddShinyMediator(); - ```csharp - var builder = WebApplication.CreateBuilder(args); - builder.Services.AddShinyMediator(); - services.AddSingletonAsImplementedInterfaces(); + // ADD YOUR HANDLER(S) + services.AddScopeAsImplementedInterfaces(); var app = builder.Build(); + // ADD REGISTERED HANDLERS THAT ARE ATTRIBUTED TO THE HTTP ENDPOINTS app.UseShinyMediatorEndpointHandlers(builder.Services); app.Run(); ``` @@ -87,4 +86,8 @@ public class MediatorHttpAttribute(string operationId, string uriTemplate, HttpM :::warning It is best to register most handlers and middleware as `Scoped` on ASP.NET Core apps +::: + +:::warning +MediatorHttpGet & MediatorHttpDelete parameters can only be set on the route or querystring ::: \ No newline at end of file