OneDeveloper
OneDeveloper
CC#
Created by OneDeveloper on 5/27/2023 in #help
✅ Generic DI in minimal APIs
I want register all the dependencies in one place for the endpoints. public static void MapAuthEndpoints(this WebApplication app) { var auth = app.MapGroup("auth"); auth.MapPost("login",LoginAsync); auth.MapGet("role/{id:Guid}",GetRoleAsync); } private static async Task<ApiResponse> LoginAsync(HttpContext context, LoginRequest loginRequest) { var response = await mediator.Send(new LoginCommand(loginRequest)); return new ApiResponse(requestPayload: requestPayload, statusCode: context.Response.StatusCode, response: response); } How can i inject IMediator once for all endpoints
34 replies
CC#
Created by OneDeveloper on 5/19/2023 in #help
✅ SignalR in .Net 6 Web API
If i am configuring this in program.cs file builder.Services.AddSignalR(); and app.MapHub<SignalRHub>("/signalr"); does this mean it can fire events at all time? I have to keep sending the events to a angular client from a large file upload operation.
26 replies