Category: NetCoreUsefullEndpoints
-
NetCoreUsefullEndpoints-part 14–adding roles and claims and authorization
I have added the current user role and claims to the nuget Usefull Endpoints for .NET Core . The endpoints are api/usefull/user/isInRole/{roleName} and api/usefull/user/claims/simple and api/usefull/user/authorization For the first one the code is pretty simple For claims and authorization,please see code at ignatandrei/NetCoreUsefullEndpoints: Usefull Endpoints for .NET Core
-
NetCoreUsefullEndpoints-part 13–adding runtime information
In the Nuget NetCoreUsefullEndpoints I have added information about the runtime information : You can access by going to localhost:5027/api/usefull/runtimeinformationAll and the end result is { “frameworkDescription”: “.NET 8.0.8”, “osDescription”: “Microsoft Windows 10.0.22631”, “processArchitecture”: “X64”, “osArchitecture”: “X64” } The code that returns this is ( I have used a Roslyn Code Generator,https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_Static#example–source-csproj-source-files-,that generates a class…
-
NetCoreUsefullEndpoints-part 12–adding url adresses
In the Nuget NetCoreUsefullEndpoints I have added information about the current process : You can access by going to localhost:5027/api/usefull/adresses and the end result is [ “http://localhost:5027″ ] The code that returns this is
-
NetCoreUsefullEndpoints-part 11–adding process information
In the Nuget NetCoreUsefullEndpoints I have added information about the current process : You can access by going to http://localhost:5027/api/usefull/process and this is the result { “id”: 24064, “processName”: “TestUsefullEndpoints”, “startTime”: “2024-06-27T23:24:36.4003351+03:00”, “totalProcessorTime”: “00:00:01.0312500”, “threadsCount”: 39, “workingSet64”: 84385792, “privateMemorySize64”: 65458176, “pagedMemorySize64”: 65458176, “pagedSystemMemorySize64”: 384840, “peakPagedMemorySize64”: 67108864, “peakVirtualMemorySize64”: 2481013948416, “peakWorkingSet64”: 84733952, “virtualMemorySize64”: 2481005563904, “basePriority”: 8, “handleCount”:…
-
NetCoreUsefullEndpoints-part 10- adding LongRunningTasks
In the Nuget NetCoreUsefullEndpoints I have already an endpoint to shutdown – see http://msprogrammer.serviciipeweb.ro/2023/02/20/netcoreusefullendpoints-part-9-adding-endpoints-for-shutdown/ . However,this means that there are no ( or some … ) long running operations that are running … How to identify those ? For the starting point,I was thinking at something simple,like an IDisposable that knows when the Long Running operation…
-
NetCoreUsefullEndpoints-part 9- adding endpoints for shutdown
In my NuGet NetCoreUsefullEndpoints package I want to can shutdown the application . Could be hard way,like calling Environment.Exit or the easy way,like calling a cancellation token. Also,what should happen with all the requests that are coming ? ( And I do not want to mention long running tasks – I do not found a…
-
NetCoreUsefullEndpoints-part 8- adding start date
In my NuGet NetCoreUsefullEndpoints package I have had already registered the actual date as var rh = route.MapGet(“api/usefull/dateUTC”,(HttpContext httpContext) => { return Results.Ok(DateTime.UtcNow); }); Now I want to register also the start date – the date where the application has been started. 1. How to do this ? 2. What will be the route ? For…
-
NetCoreUsefullEndpoints–part 7–restart application
In order to do the shutdown,I have added the following extension public static CancellationTokenSource cts=new (); public static void MapShutdown(this IEndpointRouteBuilder route,string? corsPolicy = null,string[]? authorization = null) { ArgumentNullException.ThrowIfNull(route); var rh = route.MapPost(“api/usefull/shutdown/”, (HttpContext httpContext) => { var h= cts.Token.GetHashCode(); cts?.Cancel(); return h; }); rh.AddDefault(corsPolicy,authorization); } This code defines a…
-
NetCoreUsefullEndpoints–part 6–passing to .NET 7
So .NET 7 has appeared and I decided to pass NetCoreUsefullEndpoints to .NET 7 . Also,for RateLimiter,I have considered that is good to know if the request is local or remote … so I decided to add connection ( remote IP,local IP,and more details) to the nuget package. So I have created for .NET 6…
-
[Nuget] dotnet-run-script
I found this awesome package – https://github.com/xt0rted/dotnet-run-script . It is good to make macros in global.json,then execute in a CICD scenario. For example,NetCoreUsefullEndpoints used this in yaml ( pretty standard ) # – name: Restore dependencies # run: | # cd src # cd UsefullEndpoints # dotnet tool restore # dotnet pwsh readme.ps1 # dotnet…