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.
#:package magic.library@17.3.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=magic.library&version=17.3.9
                    
Install as a Cake Addin
#tool nuget:?package=magic.library&version=17.3.9
                    
Install 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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 1,041 2/17/2024
17.3.7 207 2/12/2024
17.3.6 177 2/12/2024
17.3.5 171 2/10/2024
17.3.4 161 2/9/2024
17.3.3 168 2/8/2024
17.3.2 172 2/2/2024
17.3.1 181 1/30/2024
17.2.2 157 1/30/2024
17.2.1 190 1/22/2024
17.2.0 167 1/22/2024
17.1.7 239 1/12/2024
17.1.6 194 1/11/2024
17.1.5 210 1/5/2024
17.0.1 267 1/1/2024
17.0.0 388 12/14/2023
16.11.6 260 11/14/2023
16.11.5 202 11/12/2023
16.9.0 338 10/9/2023
16.8.5 220 9/30/2023
16.8.4 208 9/25/2023
16.8.0 185 9/24/2023
16.7.51 167 9/24/2023
16.7.50 185 9/23/2023
16.7.1 232 9/4/2023
16.7.0 351 7/11/2023
16.6.13 239 7/6/2023
16.6.12 244 7/5/2023
16.6.11 225 7/5/2023
16.6.5 268 7/3/2023
16.4.4 272 7/2/2023
16.4.3 274 6/27/2023
16.4.2 261 6/25/2023
16.4.1 272 6/25/2023
16.4.0 251 6/22/2023
16.3.2 350 6/7/2023
16.3.0 375 5/28/2023
16.2.0 447 5/13/2023
16.1.10 417 5/1/2023
16.1.9 339 4/30/2023
16.1.1 362 4/20/2023
15.10.11 382 4/16/2023
15.9.40 416 4/3/2023
15.9.1 472 3/27/2023
15.9.0 482 3/24/2023
15.8.2 514 3/20/2023
15.7.0 404 3/6/2023
15.5.20 761 2/23/2023
15.5.13 569 2/13/2023
15.5.9 461 2/11/2023
15.5.2 552 2/5/2023
15.5.1 473 2/3/2023
15.5.0 531 1/28/2023
15.2.0 676 1/18/2023
15.1.0 1,150 12/28/2022
14.5.7 685 12/13/2022
14.5.5 787 12/6/2022
14.5.1 621 11/23/2022
14.5.0 571 11/18/2022
14.4.5 640 10/22/2022
14.4.2 580 10/22/2022
14.4.1 585 10/22/2022
14.4.0 608 10/17/2022
14.3.9 637 10/13/2022
14.3.6 630 10/7/2022
14.3.2 652 9/18/2022
14.3.1 728 9/12/2022
14.3.0 622 9/10/2022
14.1.3 883 8/7/2022
14.1.2 628 8/7/2022
14.1.1 647 8/7/2022
14.0.14 627 7/26/2022
14.0.12 622 7/24/2022
14.0.11 597 7/23/2022
14.0.10 621 7/23/2022
14.0.9 604 7/23/2022
14.0.8 691 7/17/2022
14.0.5 765 7/11/2022
14.0.4 691 7/7/2022
14.0.3 681 7/2/2022
14.0.2 638 7/2/2022
14.0.1 672 7/2/2022
14.0.0 661 6/25/2022
13.4.28 644 6/11/2022
13.4.25 757 6/9/2022
13.4.24 648 6/9/2022
13.4.19 701 6/8/2022
13.4.3 684 6/6/2022
13.4.2 724 6/4/2022
13.4.0 739 5/31/2022
13.3.8 714 5/19/2022
13.3.7 671 5/18/2022
13.3.6 713 5/14/2022
13.3.4 785 5/9/2022
13.3.1 726 5/1/2022
13.3.0 689 5/1/2022
13.2.2 750 4/25/2022
13.2.1 698 4/25/2022
13.2.0 731 4/21/2022
13.1.1 747 4/20/2022
13.1.0 834 4/7/2022
13.0.0 752 4/5/2022
12.0.3 928 3/14/2022
11.0.7 794 3/11/2022
11.0.5 853 3/2/2022
11.0.4 771 2/22/2022
11.0.3 773 2/9/2022
11.0.2 843 2/6/2022
11.0.1 819 2/5/2022
10.0.21 797 1/28/2022
10.0.20 807 1/27/2022
10.0.19 790 1/23/2022
10.0.18 757 1/17/2022
10.0.17 766 1/14/2022
10.0.16 631 1/2/2022
10.0.15 684 12/31/2021
10.0.14 695 12/28/2021
10.0.13 765 12/23/2021
10.0.11 551 12/23/2021
10.0.10 577 12/22/2021
10.0.9 729 12/22/2021
10.0.8 619 12/22/2021
10.0.7 778 12/22/2021
10.0.6 655 12/19/2021
10.0.5 749 12/18/2021
10.0.3 537 12/16/2021
10.0.2 623 12/14/2021
10.0.1 505 12/13/2021
10.0.0 557 12/6/2021
9.9.9 1,335 11/29/2021
9.9.6 4,805 11/24/2021
9.9.5 556 11/23/2021
9.9.4 860 11/21/2021
9.9.3 625 11/9/2021
9.9.2 652 11/4/2021
9.9.0 742 10/30/2021
9.8.9 768 10/29/2021
9.8.7 651 10/27/2021
9.8.6 663 10/27/2021
9.8.5 748 10/26/2021
9.8.4 726 10/25/2021
9.8.3 784 10/24/2021
9.8.1 655 10/21/2021
9.8.0 724 10/20/2021
9.7.9 636 10/20/2021
9.7.8 671 10/19/2021
9.7.7 902 10/17/2021
9.7.6 796 10/17/2021
9.7.5 672 10/14/2021
9.7.1 610 10/14/2021
9.7.0 688 10/9/2021
9.6.8 699 8/30/2021
9.6.7 673 8/26/2021
9.6.6 785 8/14/2021
9.6.5 898 8/11/2021
9.6.4 690 8/10/2021
9.6.3 681 8/9/2021
9.6.2 682 8/8/2021
9.6.1 641 8/8/2021
9.5.9 842 8/5/2021
9.5.8 830 8/4/2021
9.5.3 713 7/20/2021
9.5.0 1,078 7/9/2021
9.4.5 688 6/29/2021
9.4.4 830 6/29/2021
9.4.0 675 6/24/2021
9.3.7 686 6/21/2021
9.3.6 739 6/21/2021
9.3.5 863 6/18/2021
9.3.4 795 6/18/2021
9.2.5 845 6/7/2021
9.2.4 781 6/6/2021
9.2.3 722 6/6/2021
9.2.2 633 6/4/2021
9.2.1 870 6/1/2021
9.2.0 822 5/26/2021
9.1.9 645 5/5/2021
9.1.8 805 5/5/2021
9.1.7 656 5/3/2021
9.1.4 664 4/21/2021
9.1.2 642 4/18/2021
9.1.1 641 4/15/2021
9.1.0 685 4/14/2021
9.0.1 748 4/12/2021
9.0.0 657 4/5/2021
8.9.92 1,227 3/30/2021
8.9.4 1,237 3/26/2021
8.9.3 1,284 3/19/2021
8.9.2 1,275 1/29/2021
8.9.1 1,329 1/24/2021
8.9.0 1,402 1/22/2021
8.7.1 1,696 11/15/2020
8.7.0 1,396 11/15/2020
8.6.9 1,339 11/8/2020
8.6.7 1,311 11/4/2020
8.6.6 1,396 11/2/2020
8.6.5 1,377 11/1/2020
8.6.3 1,399 10/30/2020
8.6.2 1,300 10/30/2020
8.6.1 1,390 10/29/2020
8.6.0 1,347 10/28/2020
8.5.1 1,342 10/26/2020
8.5.0 1,296 10/23/2020
8.4.6 1,510 10/20/2020
8.4.5 1,397 10/18/2020
8.4.4 1,410 10/17/2020
8.4.3 1,381 10/16/2020
8.4.2 1,335 10/16/2020
8.4.1 1,325 10/15/2020
8.4.0 1,412 10/13/2020
8.3.3 1,329 10/11/2020
8.3.2 1,371 10/8/2020
8.3.1 1,392 10/5/2020
8.3.0 1,358 10/3/2020
8.2.3 1,312 10/1/2020
8.2.2 1,573 9/26/2020
8.2.1 1,442 9/25/2020
8.2.0 1,475 9/25/2020
8.1.25 1,366 9/24/2020
8.1.24 1,359 9/23/2020
8.1.23 1,293 9/23/2020
8.1.22 1,357 9/21/2020
8.1.21 1,414 9/15/2020
8.1.20 1,425 9/14/2020
8.1.19 1,396 9/13/2020
8.1.18 1,368 9/13/2020
8.1.17 1,416 9/13/2020
8.1.16 1,416 9/13/2020
8.1.15 1,346 9/12/2020
8.1.13 1,233 9/11/2020
8.1.12 1,367 9/11/2020
8.1.11 1,364 9/11/2020
8.1.10 1,402 9/6/2020
8.1.9 1,406 9/3/2020
8.1.8 1,430 9/2/2020
8.1.7 1,298 8/28/2020
8.1.4 1,307 8/25/2020
8.1.3 1,483 8/18/2020
8.1.2 1,285 8/16/2020
8.1.1 1,347 8/15/2020
8.0.3 1,364 8/11/2020
8.0.2 1,394 8/7/2020
8.0.1 1,389 8/7/2020
8.0.0 1,332 8/7/2020
7.0.1 1,446 6/28/2020
7.0.0 1,443 6/28/2020
5.0.10 1,416 5/31/2020
5.0.9 1,514 5/30/2020
5.0.8 1,381 5/29/2020
5.0.7 1,373 5/29/2020
5.0.5 1,446 2/27/2020
5.0.4 1,410 2/26/2020
5.0.3 1,401 2/26/2020
5.0.2 1,408 2/25/2020
5.0.1 1,311 2/25/2020
5.0.0 1,436 2/25/2020
4.1.5 1,375 2/23/2020
4.1.4 1,457 2/23/2020
4.1.3 1,388 2/22/2020
4.1.2 1,385 2/22/2020
4.1.1 1,373 2/21/2020
4.1.0 1,413 2/21/2020
4.0.9 1,496 2/7/2020
4.0.8 1,336 2/7/2020
4.0.7 1,355 2/7/2020
4.0.5 1,369 1/28/2020
4.0.4 1,500 1/27/2020
4.0.3 1,350 1/27/2020
4.0.2 1,497 1/16/2020
4.0.1 1,513 1/11/2020
4.0.0 1,465 1/5/2020
3.1.7 1,513 12/17/2019
3.1.6 1,410 12/12/2019
3.1.5 1,407 12/12/2019
3.1.4 1,413 12/5/2019
3.1.3 1,447 12/4/2019
3.1.2 1,476 11/30/2019
3.1.1 1,629 11/26/2019
3.1.0 1,442 11/10/2019
3.0.4 1,276 11/1/2019
3.0.3 1,443 10/28/2019
3.0.2 1,457 10/28/2019
3.0.1 1,453 10/26/2019
3.0.0 1,274 10/23/2019
2.1.4 1,076 10/21/2019
2.1.3 1,409 10/21/2019
2.1.2 1,549 10/21/2019
2.1.1 1,421 10/19/2019
2.1.0 1,472 10/19/2019
2.0.9 1,171 10/18/2019
2.0.8 1,431 10/18/2019
2.0.7 1,174 10/18/2019
2.0.6 1,159 10/18/2019
2.0.5 1,211 10/18/2019
2.0.4 1,171 10/17/2019
2.0.3 1,308 10/16/2019
2.0.2 1,297 10/15/2019
2.0.1 1,331 10/14/2019
2.0.0 1,173 10/13/2019
1.1.7 1,515 10/11/2019
1.1.6 1,458 10/11/2019