magic.library 17.3.9

dotnet add package magic.library --version 17.3.9
                    
NuGet\Install-Package magic.library -Version 17.3.9
                    
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="17.3.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="magic.library" Version="17.3.9" />
                    
Directory.Packages.props
<PackageReference Include="magic.library" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add magic.library --version 17.3.9
                    
#r "nuget: magic.library, 17.3.9"
                    
#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.
#addin nuget:?package=magic.library&version=17.3.9
                    
Install magic.library as a Cake Addin
#tool nuget:?package=magic.library&version=17.3.9
                    
Install magic.library as a Cake Tool

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 8 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.

Magic's GitHub project page

Magic is 100% Open Source and you can find the primary project GitHub page here.

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 Thomas Hansen 2023 - 2024, and professionally maintained by AINIRO.IO.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
17.3.9 296 2/17/2024
17.3.7 164 2/12/2024
17.3.6 132 2/12/2024
17.3.5 122 2/10/2024
17.3.4 121 2/9/2024
17.3.3 127 2/8/2024
17.3.2 131 2/2/2024
17.3.1 138 1/30/2024
17.2.2 109 1/30/2024
17.2.1 149 1/22/2024
17.2.0 124 1/22/2024
17.1.7 193 1/12/2024
17.1.6 155 1/11/2024
17.1.5 163 1/5/2024
17.0.1 222 1/1/2024
17.0.0 348 12/14/2023
16.11.6 246 11/14/2023
16.11.5 190 11/12/2023
16.9.0 308 10/9/2023
16.8.5 189 9/30/2023
16.8.4 184 9/25/2023
16.8.0 154 9/24/2023
16.7.51 149 9/24/2023
16.7.50 159 9/23/2023
16.7.1 205 9/4/2023
16.7.0 316 7/11/2023
16.6.13 204 7/6/2023
16.6.12 201 7/5/2023
16.6.11 190 7/5/2023
16.6.5 227 7/3/2023
16.4.4 227 7/2/2023
16.4.3 240 6/27/2023
16.4.2 228 6/25/2023
16.4.1 228 6/25/2023
16.4.0 214 6/22/2023
16.3.2 309 6/7/2023
16.3.0 319 5/28/2023
16.2.0 398 5/13/2023
16.1.10 379 5/1/2023
16.1.9 298 4/30/2023
16.1.1 319 4/20/2023
15.10.11 340 4/16/2023
15.9.40 374 4/3/2023
15.9.1 431 3/27/2023
15.9.0 436 3/24/2023
15.8.2 475 3/20/2023
15.7.0 356 3/6/2023
15.5.20 725 2/23/2023
15.5.13 527 2/13/2023
15.5.9 421 2/11/2023
15.5.2 503 2/5/2023
15.5.1 418 2/3/2023
15.5.0 491 1/28/2023
15.2.0 636 1/18/2023
15.1.0 1,107 12/28/2022
14.5.7 645 12/13/2022
14.5.5 748 12/6/2022
14.5.1 582 11/23/2022
14.5.0 528 11/18/2022
14.4.5 605 10/22/2022
14.4.2 536 10/22/2022
14.4.1 538 10/22/2022
14.4.0 571 10/17/2022
14.3.9 601 10/13/2022
14.3.6 593 10/7/2022
14.3.2 603 9/18/2022
14.3.1 685 9/12/2022
14.3.0 578 9/10/2022
14.1.3 840 8/7/2022
14.1.2 589 8/7/2022
14.1.1 598 8/7/2022
14.0.14 589 7/26/2022
14.0.12 579 7/24/2022
14.0.11 555 7/23/2022
14.0.10 575 7/23/2022
14.0.9 557 7/23/2022
14.0.8 645 7/17/2022
14.0.5 714 7/11/2022
14.0.4 649 7/7/2022
14.0.3 640 7/2/2022
14.0.2 584 7/2/2022
14.0.1 630 7/2/2022
14.0.0 609 6/25/2022
13.4.28 601 6/11/2022
13.4.25 712 6/9/2022
13.4.24 603 6/9/2022
13.4.19 656 6/8/2022
13.4.3 632 6/6/2022
13.4.2 668 6/4/2022
13.4.0 689 5/31/2022
13.3.8 663 5/19/2022
13.3.7 624 5/18/2022
13.3.6 666 5/14/2022
13.3.4 742 5/9/2022
13.3.1 674 5/1/2022
13.3.0 633 5/1/2022
13.2.2 693 4/25/2022
13.2.1 649 4/25/2022
13.2.0 684 4/21/2022
13.1.1 697 4/20/2022
13.1.0 773 4/7/2022
13.0.0 707 4/5/2022
12.0.3 870 3/14/2022
11.0.7 747 3/11/2022
11.0.5 804 3/2/2022
11.0.4 724 2/22/2022
11.0.3 724 2/9/2022
11.0.2 780 2/6/2022
11.0.1 771 2/5/2022
10.0.21 738 1/28/2022
10.0.20 755 1/27/2022
10.0.19 742 1/23/2022
10.0.18 708 1/17/2022
10.0.17 719 1/14/2022
10.0.16 572 1/2/2022
10.0.15 630 12/31/2021
10.0.14 641 12/28/2021
10.0.13 711 12/23/2021
10.0.11 501 12/23/2021
10.0.10 521 12/22/2021
10.0.9 678 12/22/2021
10.0.8 567 12/22/2021
10.0.7 721 12/22/2021
10.0.6 605 12/19/2021
10.0.5 698 12/18/2021
10.0.3 483 12/16/2021
10.0.2 563 12/14/2021
10.0.1 453 12/13/2021
10.0.0 499 12/6/2021
9.9.9 1,286 11/29/2021
9.9.6 4,754 11/24/2021
9.9.5 505 11/23/2021
9.9.4 805 11/21/2021
9.9.3 572 11/9/2021
9.9.2 591 11/4/2021
9.9.0 692 10/30/2021
9.8.9 714 10/29/2021
9.8.7 599 10/27/2021
9.8.6 607 10/27/2021
9.8.5 700 10/26/2021
9.8.4 673 10/25/2021
9.8.3 726 10/24/2021
9.8.1 596 10/21/2021
9.8.0 671 10/20/2021
9.7.9 586 10/20/2021
9.7.8 618 10/19/2021
9.7.7 853 10/17/2021
9.7.6 748 10/17/2021
9.7.5 624 10/14/2021
9.7.1 561 10/14/2021
9.7.0 637 10/9/2021
9.6.8 648 8/30/2021
9.6.7 625 8/26/2021
9.6.6 737 8/14/2021
9.6.5 840 8/11/2021
9.6.4 634 8/10/2021
9.6.3 631 8/9/2021
9.6.2 624 8/8/2021
9.6.1 582 8/8/2021
9.5.9 778 8/5/2021
9.5.8 774 8/4/2021
9.5.3 659 7/20/2021
9.5.0 1,026 7/9/2021
9.4.5 635 6/29/2021
9.4.4 782 6/29/2021
9.4.0 627 6/24/2021
9.3.7 634 6/21/2021
9.3.6 686 6/21/2021
9.3.5 813 6/18/2021
9.3.4 743 6/18/2021
9.2.5 792 6/7/2021
9.2.4 731 6/6/2021
9.2.3 668 6/6/2021
9.2.2 575 6/4/2021
9.2.1 811 6/1/2021
9.2.0 768 5/26/2021
9.1.9 586 5/5/2021
9.1.8 738 5/5/2021
9.1.7 597 5/3/2021
9.1.4 604 4/21/2021
9.1.2 590 4/18/2021
9.1.1 576 4/15/2021
9.1.0 631 4/14/2021
9.0.1 697 4/12/2021
9.0.0 594 4/5/2021
8.9.92 1,168 3/30/2021
8.9.4 1,178 3/26/2021
8.9.3 1,221 3/19/2021
8.9.2 1,204 1/29/2021
8.9.1 1,271 1/24/2021
8.9.0 1,336 1/22/2021
8.7.1 1,637 11/15/2020
8.7.0 1,341 11/15/2020
8.6.9 1,278 11/8/2020
8.6.7 1,249 11/4/2020
8.6.6 1,336 11/2/2020
8.6.5 1,316 11/1/2020
8.6.3 1,337 10/30/2020
8.6.2 1,239 10/30/2020
8.6.1 1,330 10/29/2020
8.6.0 1,290 10/28/2020
8.5.1 1,279 10/26/2020
8.5.0 1,229 10/23/2020
8.4.6 1,447 10/20/2020
8.4.5 1,331 10/18/2020
8.4.4 1,352 10/17/2020
8.4.3 1,320 10/16/2020
8.4.2 1,267 10/16/2020
8.4.1 1,266 10/15/2020
8.4.0 1,345 10/13/2020
8.3.3 1,267 10/11/2020
8.3.2 1,310 10/8/2020
8.3.1 1,327 10/5/2020
8.3.0 1,289 10/3/2020
8.2.3 1,235 10/1/2020
8.2.2 1,516 9/26/2020
8.2.1 1,376 9/25/2020
8.2.0 1,409 9/25/2020
8.1.25 1,306 9/24/2020
8.1.24 1,298 9/23/2020
8.1.23 1,226 9/23/2020
8.1.22 1,298 9/21/2020
8.1.21 1,351 9/15/2020
8.1.20 1,361 9/14/2020
8.1.19 1,336 9/13/2020
8.1.18 1,304 9/13/2020
8.1.17 1,354 9/13/2020
8.1.16 1,353 9/13/2020
8.1.15 1,278 9/12/2020
8.1.13 1,173 9/11/2020
8.1.12 1,297 9/11/2020
8.1.11 1,300 9/11/2020
8.1.10 1,343 9/6/2020
8.1.9 1,341 9/3/2020
8.1.8 1,367 9/2/2020
8.1.7 1,235 8/28/2020
8.1.4 1,237 8/25/2020
8.1.3 1,415 8/18/2020
8.1.2 1,227 8/16/2020
8.1.1 1,288 8/15/2020
8.0.3 1,303 8/11/2020
8.0.2 1,324 8/7/2020
8.0.1 1,325 8/7/2020
8.0.0 1,273 8/7/2020
7.0.1 1,383 6/28/2020
7.0.0 1,377 6/28/2020
5.0.10 1,345 5/31/2020
5.0.9 1,445 5/30/2020
5.0.8 1,322 5/29/2020
5.0.7 1,300 5/29/2020
5.0.5 1,381 2/27/2020
5.0.4 1,348 2/26/2020
5.0.3 1,339 2/26/2020
5.0.2 1,346 2/25/2020
5.0.1 1,248 2/25/2020
5.0.0 1,369 2/25/2020
4.1.5 1,309 2/23/2020
4.1.4 1,391 2/23/2020
4.1.3 1,325 2/22/2020
4.1.2 1,319 2/22/2020
4.1.1 1,311 2/21/2020
4.1.0 1,341 2/21/2020
4.0.9 1,432 2/7/2020
4.0.8 1,272 2/7/2020
4.0.7 1,289 2/7/2020
4.0.5 1,302 1/28/2020
4.0.4 1,434 1/27/2020
4.0.3 1,286 1/27/2020
4.0.2 1,430 1/16/2020
4.0.1 1,451 1/11/2020
4.0.0 1,399 1/5/2020
3.1.7 1,449 12/17/2019
3.1.6 1,339 12/12/2019
3.1.5 1,337 12/12/2019
3.1.4 1,350 12/5/2019
3.1.3 1,383 12/4/2019
3.1.2 1,406 11/30/2019
3.1.1 1,568 11/26/2019
3.1.0 1,368 11/10/2019
3.0.4 1,210 11/1/2019
3.0.3 1,376 10/28/2019
3.0.2 1,390 10/28/2019
3.0.1 1,380 10/26/2019
3.0.0 1,208 10/23/2019
2.1.4 1,005 10/21/2019
2.1.3 1,341 10/21/2019
2.1.2 1,472 10/21/2019
2.1.1 1,349 10/19/2019
2.1.0 1,397 10/19/2019
2.0.9 1,097 10/18/2019
2.0.8 1,366 10/18/2019
2.0.7 1,103 10/18/2019
2.0.6 1,091 10/18/2019
2.0.5 1,147 10/18/2019
2.0.4 1,105 10/17/2019
2.0.3 1,239 10/16/2019
2.0.2 1,224 10/15/2019
2.0.1 1,265 10/14/2019
2.0.0 1,101 10/13/2019
1.1.7 1,434 10/11/2019
1.1.6 1,383 10/11/2019