magic.library 16.3.0

.NET 6.0
dotnet add package magic.library --version 16.3.0
NuGet\Install-Package magic.library -Version 16.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.library" Version="16.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.library --version 16.3.0
#r "nuget: magic.library, 16.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.library as a Cake Addin
#addin nuget:?package=magic.library&version=16.3.0

// Install magic.library as a Cake Tool
#tool nuget:?package=magic.library&version=16.3.0

magic.library - Tying Magic together

This project helps you to wire up everything related to Magic. Normally you'd use it simply like the following from your startup class in your .Net 6 Web API project.

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using magic.library;

namespace magic.backend
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            // Initializing Magic.
            services.AddMagic(Configuration);
        }

        public void Configure(IApplicationBuilder app)
        {
            // Initializing Magic.
            app.UseMagic(Configuration);
        }
    }
}

However, you can also take more control over how things are actually wired up, by instead of using the "do all methods" called AddMagic and UseMagic, invoke some of the specialized initialization methods, you can find below.

  • IServiceCollection.AddMagicCaching
  • IServiceCollection.AddMagicHttp
  • IServiceCollection.AddMagicLogging
  • IServiceCollection.AddMagicSignals
  • IServiceCollection.AddMagicExceptions
  • IServiceCollection.AddMagicEndpoints
  • IServiceCollection.AddMagicAuthorization
  • IServiceCollection.AddMagicFileServices
  • IServiceCollection.AddMagicFileServices
  • IServiceCollection.AddMagicConfiguration
  • IServiceCollection.AddMagicScheduler
  • IServiceCollection.AddMagicMail
  • IServiceCollection.AddMagicLambda
  • IServiceCollection.AddMagicSockets

The above methods is basically what the AddMagic method actually does, and they're extension methods of IServiceCollection, that can be found in the magic.library namespace. Similar alternatives to UseMagic can be found below.

  • IApplicationBuilder.UseMagicExceptions
  • IApplicationBuilder.UseMagicStartupFiles
  • IApplicationBuilder.UseMagicScheduler
  • IApplicationBuilder.UseMagicCors

If you use these methods instead of the "do all methods", your motivation would probably be to replace one of these methods with your own implementation, to exchange the default wiring, by (for instance) using a "virtual database based file system" by creating your own service implementation of for instance IFileService from "magic.lambda.io", or use a different logging provider than the default, etc. If you wish to do this, you'd probably benefit from looking at what the default implementation of your method does, to understand the requirements from your method. Doing this is very powerful, and allows you to change the way the system behaves by default - But is also definitely considered an "advanced exercise".

Exceptions handlers

Magic allows you to provide a custom exceptions handler on a per folder level. This overrides the default exception logic with a custom exception handler expected to be named "exceptions.hl" and found within the folder hierarchy where an HTTP invocation is resolved. For instance, if you wish to create your own exception handler for a specific module called "foo", you can create an exception handler file called "/files/modules/foo/exceptions.hl", and expect this file to be invoked every time an unhandled exception occurs, anywhere inside of your "foo" folder. This allows you to transform an unhandled exception, such as for instance localising it or customising it in any ways. Your custom exception handler will be invoked with the following arguments.

  • [message] - The exception error message
  • [path] - The URL that triggered the exception
  • [field] - If the exception that was thrown declared a field, this argument will contain the name of the field
  • [status] - If the exception that was thrown declared a status code, this argument will contain the status code
  • [public] - If the exception that was thrown wants to propagate to the client this will be true

You can return a "transformed" exception from your exception handler, returning the following arguments, that will end up becoming the response object returned to the client.

  • [message] - Message to return as JSON to client
  • [field] - Field to return as JSON to client
  • [status] - Status code to decorate your HTTP response with

The default exception handler can be found in "/files/exceptions.hl", which will be invoked if no custom exception handler is declared further down in your folder hierarchy.

Project website for magic.lambda.library

The source code for this repository can be found at github.com/polterguy/magic.library, and you can provide feedback, provide bug reports, etc at the same place.

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities

The projects is copyright of Aista, Ltd 2021 - 2023, and professionally maintained by AINIRO your friendly ChatGPT website chatbot vendor.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
16.3.0 85 5/28/2023
16.2.0 206 5/13/2023
16.1.10 205 5/1/2023
16.1.9 131 4/30/2023
16.1.1 157 4/20/2023
15.10.11 176 4/16/2023
15.9.40 191 4/3/2023
15.9.1 259 3/27/2023
15.9.0 262 3/24/2023
15.8.2 299 3/20/2023
15.7.0 183 3/6/2023
15.5.20 534 2/23/2023
15.5.13 333 2/13/2023
15.5.9 204 2/11/2023
15.5.2 233 2/5/2023
15.5.1 237 2/3/2023
15.5.0 299 1/28/2023
15.2.0 440 1/18/2023
15.1.0 928 12/28/2022
14.5.7 470 12/13/2022
14.5.5 563 12/6/2022
14.5.1 411 11/23/2022
14.5.0 367 11/18/2022
14.4.5 424 10/22/2022
14.4.2 360 10/22/2022
14.4.1 353 10/22/2022
14.4.0 381 10/17/2022
14.3.9 392 10/13/2022
14.3.6 407 10/7/2022
14.3.2 419 9/18/2022
14.3.1 543 9/12/2022
14.3.0 404 9/10/2022
14.1.3 688 8/7/2022
14.1.2 435 8/7/2022
14.1.1 423 8/7/2022
14.0.14 440 7/26/2022
14.0.12 431 7/24/2022
14.0.11 408 7/23/2022
14.0.10 419 7/23/2022
14.0.9 424 7/23/2022
14.0.8 504 7/17/2022
14.0.5 565 7/11/2022
14.0.4 510 7/7/2022
14.0.3 492 7/2/2022
14.0.2 446 7/2/2022
14.0.1 473 7/2/2022
14.0.0 462 6/25/2022
13.4.28 433 6/11/2022
13.4.25 549 6/9/2022
13.4.24 459 6/9/2022
13.4.19 509 6/8/2022
13.4.3 464 6/6/2022
13.4.2 515 6/4/2022
13.4.0 534 5/31/2022
13.3.8 506 5/19/2022
13.3.7 467 5/18/2022
13.3.6 520 5/14/2022
13.3.4 581 5/9/2022
13.3.1 533 5/1/2022
13.3.0 495 5/1/2022
13.2.2 549 4/25/2022
13.2.1 496 4/25/2022
13.2.0 534 4/21/2022
13.1.1 542 4/20/2022
13.1.0 611 4/7/2022
13.0.0 545 4/5/2022
12.0.3 669 3/14/2022
11.0.7 564 3/11/2022
11.0.5 630 3/2/2022
11.0.4 563 2/22/2022
11.0.3 571 2/9/2022
11.0.2 627 2/6/2022
11.0.1 610 2/5/2022
10.0.21 570 1/28/2022
10.0.20 586 1/27/2022
10.0.19 577 1/23/2022
10.0.18 554 1/17/2022
10.0.17 563 1/14/2022
10.0.16 426 1/2/2022
10.0.15 479 12/31/2021
10.0.14 488 12/28/2021
10.0.13 568 12/23/2021
10.0.11 356 12/23/2021
10.0.10 372 12/22/2021
10.0.9 547 12/22/2021
10.0.8 413 12/22/2021
10.0.7 558 12/22/2021
10.0.6 450 12/19/2021
10.0.5 554 12/18/2021
10.0.3 341 12/16/2021
10.0.2 415 12/14/2021
10.0.1 305 12/13/2021
10.0.0 348 12/6/2021
9.9.9 1,110 11/29/2021
9.9.6 4,600 11/24/2021
9.9.5 346 11/23/2021
9.9.4 655 11/21/2021
9.9.3 418 11/9/2021
9.9.2 439 11/4/2021
9.9.0 540 10/30/2021
9.8.9 554 10/29/2021
9.8.7 451 10/27/2021
9.8.6 437 10/27/2021
9.8.5 569 10/26/2021
9.8.4 502 10/25/2021
9.8.3 578 10/24/2021
9.8.1 440 10/21/2021
9.8.0 518 10/20/2021
9.7.9 449 10/20/2021
9.7.8 467 10/19/2021
9.7.7 695 10/17/2021
9.7.6 596 10/17/2021
9.7.5 464 10/14/2021
9.7.1 416 10/14/2021
9.7.0 481 10/9/2021
9.6.8 490 8/30/2021
9.6.7 461 8/26/2021
9.6.6 585 8/14/2021
9.6.5 683 8/11/2021
9.6.4 485 8/10/2021
9.6.3 487 8/9/2021
9.6.2 458 8/8/2021
9.6.1 424 8/8/2021
9.5.9 621 8/5/2021
9.5.8 617 8/4/2021
9.5.3 511 7/20/2021
9.5.0 844 7/9/2021
9.4.5 490 6/29/2021
9.4.4 621 6/29/2021
9.4.0 460 6/24/2021
9.3.7 486 6/21/2021
9.3.6 535 6/21/2021
9.3.5 669 6/18/2021
9.3.4 585 6/18/2021
9.2.5 642 6/7/2021
9.2.4 562 6/6/2021
9.2.3 509 6/6/2021
9.2.2 438 6/4/2021
9.2.1 650 6/1/2021
9.2.0 628 5/26/2021
9.1.9 425 5/5/2021
9.1.8 579 5/5/2021
9.1.7 441 5/3/2021
9.1.4 454 4/21/2021
9.1.2 437 4/18/2021
9.1.1 422 4/15/2021
9.1.0 472 4/14/2021
9.0.1 545 4/12/2021
9.0.0 452 4/5/2021
8.9.92 1,000 3/30/2021
8.9.4 1,036 3/26/2021
8.9.3 1,045 3/19/2021
8.9.2 1,041 1/29/2021
8.9.1 1,103 1/24/2021
8.9.0 1,165 1/22/2021
8.7.1 1,449 11/15/2020
8.7.0 1,154 11/15/2020
8.6.9 1,115 11/8/2020
8.6.7 1,087 11/4/2020
8.6.6 1,175 11/2/2020
8.6.5 1,143 11/1/2020
8.6.3 1,149 10/30/2020
8.6.2 1,062 10/30/2020
8.6.1 1,166 10/29/2020
8.6.0 1,094 10/28/2020
8.5.1 1,089 10/26/2020
8.5.0 1,069 10/23/2020
8.4.6 1,271 10/20/2020
8.4.5 1,112 10/18/2020
8.4.4 1,175 10/17/2020
8.4.3 1,142 10/16/2020
8.4.2 1,102 10/16/2020
8.4.1 1,092 10/15/2020
8.4.0 1,155 10/13/2020
8.3.3 1,081 10/11/2020
8.3.2 1,146 10/8/2020
8.3.1 1,140 10/5/2020
8.3.0 1,104 10/3/2020
8.2.3 1,034 10/1/2020
8.2.2 1,300 9/26/2020
8.2.1 1,178 9/25/2020
8.2.0 1,219 9/25/2020
8.1.25 1,135 9/24/2020
8.1.24 1,111 9/23/2020
8.1.23 1,075 9/23/2020
8.1.22 1,127 9/21/2020
8.1.21 1,175 9/15/2020
8.1.20 1,200 9/14/2020
8.1.19 1,138 9/13/2020
8.1.18 1,127 9/13/2020
8.1.17 1,176 9/13/2020
8.1.16 1,181 9/13/2020
8.1.15 1,101 9/12/2020
8.1.13 1,012 9/11/2020
8.1.12 1,122 9/11/2020
8.1.11 1,113 9/11/2020
8.1.10 1,170 9/6/2020
8.1.9 1,169 9/3/2020
8.1.8 1,199 9/2/2020
8.1.7 1,039 8/28/2020
8.1.4 1,060 8/25/2020
8.1.3 1,186 8/18/2020
8.1.2 1,052 8/16/2020
8.1.1 1,124 8/15/2020
8.0.3 1,108 8/11/2020
8.0.2 1,143 8/7/2020
8.0.1 1,118 8/7/2020
8.0.0 1,093 8/7/2020
7.0.1 1,195 6/28/2020
7.0.0 1,180 6/28/2020
5.0.10 1,149 5/31/2020
5.0.9 1,243 5/30/2020
5.0.8 1,147 5/29/2020
5.0.7 1,105 5/29/2020
5.0.5 1,217 2/27/2020
5.0.4 1,155 2/26/2020
5.0.3 1,159 2/26/2020
5.0.2 1,149 2/25/2020
5.0.1 1,056 2/25/2020
5.0.0 1,167 2/25/2020
4.1.5 1,132 2/23/2020
4.1.4 1,210 2/23/2020
4.1.3 1,151 2/22/2020
4.1.2 1,138 2/22/2020
4.1.1 1,131 2/21/2020
4.1.0 1,166 2/21/2020
4.0.9 1,231 2/7/2020
4.0.8 1,057 2/7/2020
4.0.7 1,089 2/7/2020
4.0.5 1,124 1/28/2020
4.0.4 1,249 1/27/2020
4.0.3 1,120 1/27/2020
4.0.2 1,205 1/16/2020
4.0.1 1,250 1/11/2020
4.0.0 1,209 1/5/2020
3.1.7 1,254 12/17/2019
3.1.6 1,175 12/12/2019
3.1.5 1,169 12/12/2019
3.1.4 1,186 12/5/2019
3.1.3 1,215 12/4/2019
3.1.2 1,232 11/30/2019
3.1.1 1,367 11/26/2019
3.1.0 1,189 11/10/2019
3.0.4 1,008 11/1/2019
3.0.3 1,179 10/28/2019
3.0.2 1,222 10/28/2019
3.0.1 1,210 10/26/2019
3.0.0 1,036 10/23/2019
2.1.4 798 10/21/2019
2.1.3 1,181 10/21/2019
2.1.2 1,267 10/21/2019
2.1.1 1,144 10/19/2019
2.1.0 1,212 10/19/2019
2.0.9 905 10/18/2019
2.0.8 1,186 10/18/2019
2.0.7 917 10/18/2019
2.0.6 910 10/18/2019
2.0.5 955 10/18/2019
2.0.4 922 10/17/2019
2.0.3 1,041 10/16/2019
2.0.2 1,048 10/15/2019
2.0.1 1,087 10/14/2019
2.0.0 791 10/13/2019
1.1.7 1,222 10/11/2019
1.1.6 1,199 10/11/2019