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,243 2/17/2024
17.3.7 219 2/12/2024
17.3.6 192 2/12/2024
17.3.5 184 2/10/2024
17.3.4 173 2/9/2024
17.3.3 180 2/8/2024
17.3.2 185 2/2/2024
17.3.1 195 1/30/2024
17.2.2 169 1/30/2024
17.2.1 202 1/22/2024
17.2.0 179 1/22/2024
17.1.7 251 1/12/2024
17.1.6 206 1/11/2024
17.1.5 223 1/5/2024
17.0.1 279 1/1/2024
17.0.0 400 12/14/2023
16.11.6 266 11/14/2023
16.11.5 209 11/12/2023
16.9.0 342 10/9/2023
16.8.5 224 9/30/2023
16.8.4 212 9/25/2023
16.8.0 189 9/24/2023
16.7.51 171 9/24/2023
16.7.50 191 9/23/2023
16.7.1 243 9/4/2023
16.7.0 360 7/11/2023
16.6.13 247 7/6/2023
16.6.12 252 7/5/2023
16.6.11 234 7/5/2023
16.6.5 276 7/3/2023
16.4.4 281 7/2/2023
16.4.3 282 6/27/2023
16.4.2 270 6/25/2023
16.4.1 284 6/25/2023
16.4.0 260 6/22/2023
16.3.2 360 6/7/2023
16.3.0 385 5/28/2023
16.2.0 457 5/13/2023
16.1.10 426 5/1/2023
16.1.9 350 4/30/2023
16.1.1 375 4/20/2023
15.10.11 391 4/16/2023
15.9.40 425 4/3/2023
15.9.1 483 3/27/2023
15.9.0 494 3/24/2023
15.8.2 524 3/20/2023
15.7.0 418 3/6/2023
15.5.20 771 2/23/2023
15.5.13 582 2/13/2023
15.5.9 475 2/11/2023
15.5.2 564 2/5/2023
15.5.1 484 2/3/2023
15.5.0 541 1/28/2023
15.2.0 686 1/18/2023
15.1.0 1,161 12/28/2022
14.5.7 695 12/13/2022
14.5.5 798 12/6/2022
14.5.1 634 11/23/2022
14.5.0 582 11/18/2022
14.4.5 650 10/22/2022
14.4.2 591 10/22/2022
14.4.1 597 10/22/2022
14.4.0 618 10/17/2022
14.3.9 648 10/13/2022
14.3.6 640 10/7/2022
14.3.2 662 9/18/2022
14.3.1 739 9/12/2022
14.3.0 632 9/10/2022
14.1.3 893 8/7/2022
14.1.2 638 8/7/2022
14.1.1 660 8/7/2022
14.0.14 637 7/26/2022
14.0.12 632 7/24/2022
14.0.11 606 7/23/2022
14.0.10 632 7/23/2022
14.0.9 617 7/23/2022
14.0.8 701 7/17/2022
14.0.5 782 7/11/2022
14.0.4 701 7/7/2022
14.0.3 692 7/2/2022
14.0.2 650 7/2/2022
14.0.1 684 7/2/2022
14.0.0 672 6/25/2022
13.4.28 655 6/11/2022
13.4.25 768 6/9/2022
13.4.24 659 6/9/2022
13.4.19 712 6/8/2022
13.4.3 695 6/6/2022
13.4.2 734 6/4/2022
13.4.0 752 5/31/2022
13.3.8 724 5/19/2022
13.3.7 684 5/18/2022
13.3.6 723 5/14/2022
13.3.4 795 5/9/2022
13.3.1 740 5/1/2022
13.3.0 699 5/1/2022
13.2.2 763 4/25/2022
13.2.1 708 4/25/2022
13.2.0 741 4/21/2022
13.1.1 759 4/20/2022
13.1.0 848 4/7/2022
13.0.0 763 4/5/2022
12.0.3 939 3/14/2022
11.0.7 804 3/11/2022
11.0.5 863 3/2/2022
11.0.4 781 2/22/2022
11.0.3 784 2/9/2022
11.0.2 854 2/6/2022
11.0.1 830 2/5/2022
10.0.21 809 1/28/2022
10.0.20 820 1/27/2022
10.0.19 801 1/23/2022
10.0.18 767 1/17/2022
10.0.17 776 1/14/2022
10.0.16 642 1/2/2022
10.0.15 695 12/31/2021
10.0.14 706 12/28/2021
10.0.13 776 12/23/2021
10.0.11 561 12/23/2021
10.0.10 588 12/22/2021
10.0.9 739 12/22/2021
10.0.8 629 12/22/2021
10.0.7 789 12/22/2021
10.0.6 665 12/19/2021
10.0.5 763 12/18/2021
10.0.3 548 12/16/2021
10.0.2 633 12/14/2021
10.0.1 516 12/13/2021
10.0.0 567 12/6/2021
9.9.9 1,345 11/29/2021
9.9.6 4,815 11/24/2021
9.9.5 566 11/23/2021
9.9.4 871 11/21/2021
9.9.3 636 11/9/2021
9.9.2 662 11/4/2021
9.9.0 753 10/30/2021
9.8.9 779 10/29/2021
9.8.7 662 10/27/2021
9.8.6 675 10/27/2021
9.8.5 758 10/26/2021
9.8.4 736 10/25/2021
9.8.3 796 10/24/2021
9.8.1 665 10/21/2021
9.8.0 734 10/20/2021
9.7.9 646 10/20/2021
9.7.8 681 10/19/2021
9.7.7 912 10/17/2021
9.7.6 806 10/17/2021
9.7.5 684 10/14/2021
9.7.1 620 10/14/2021
9.7.0 699 10/9/2021
9.6.8 709 8/30/2021
9.6.7 684 8/26/2021
9.6.6 795 8/14/2021
9.6.5 909 8/11/2021
9.6.4 701 8/10/2021
9.6.3 691 8/9/2021
9.6.2 696 8/8/2021
9.6.1 652 8/8/2021
9.5.9 852 8/5/2021
9.5.8 845 8/4/2021
9.5.3 723 7/20/2021
9.5.0 1,088 7/9/2021
9.4.5 699 6/29/2021
9.4.4 840 6/29/2021
9.4.0 685 6/24/2021
9.3.7 698 6/21/2021
9.3.6 750 6/21/2021
9.3.5 873 6/18/2021
9.3.4 805 6/18/2021
9.2.5 856 6/7/2021
9.2.4 791 6/6/2021
9.2.3 736 6/6/2021
9.2.2 645 6/4/2021
9.2.1 881 6/1/2021
9.2.0 834 5/26/2021
9.1.9 658 5/5/2021
9.1.8 816 5/5/2021
9.1.7 668 5/3/2021
9.1.4 675 4/21/2021
9.1.2 652 4/18/2021
9.1.1 652 4/15/2021
9.1.0 695 4/14/2021
9.0.1 758 4/12/2021
9.0.0 668 4/5/2021
8.9.92 1,237 3/30/2021
8.9.4 1,250 3/26/2021
8.9.3 1,298 3/19/2021
8.9.2 1,288 1/29/2021
8.9.1 1,341 1/24/2021
8.9.0 1,417 1/22/2021
8.7.1 1,708 11/15/2020
8.7.0 1,408 11/15/2020
8.6.9 1,351 11/8/2020
8.6.7 1,324 11/4/2020
8.6.6 1,409 11/2/2020
8.6.5 1,390 11/1/2020
8.6.3 1,412 10/30/2020
8.6.2 1,313 10/30/2020
8.6.1 1,404 10/29/2020
8.6.0 1,359 10/28/2020
8.5.1 1,359 10/26/2020
8.5.0 1,311 10/23/2020
8.4.6 1,523 10/20/2020
8.4.5 1,411 10/18/2020
8.4.4 1,424 10/17/2020
8.4.3 1,396 10/16/2020
8.4.2 1,347 10/16/2020
8.4.1 1,337 10/15/2020
8.4.0 1,425 10/13/2020
8.3.3 1,342 10/11/2020
8.3.2 1,384 10/8/2020
8.3.1 1,406 10/5/2020
8.3.0 1,370 10/3/2020
8.2.3 1,327 10/1/2020
8.2.2 1,585 9/26/2020
8.2.1 1,456 9/25/2020
8.2.0 1,491 9/25/2020
8.1.25 1,378 9/24/2020
8.1.24 1,371 9/23/2020
8.1.23 1,305 9/23/2020
8.1.22 1,368 9/21/2020
8.1.21 1,425 9/15/2020
8.1.20 1,439 9/14/2020
8.1.19 1,407 9/13/2020
8.1.18 1,384 9/13/2020
8.1.17 1,427 9/13/2020
8.1.16 1,427 9/13/2020
8.1.15 1,358 9/12/2020
8.1.13 1,244 9/11/2020
8.1.12 1,380 9/11/2020
8.1.11 1,376 9/11/2020
8.1.10 1,413 9/6/2020
8.1.9 1,419 9/3/2020
8.1.8 1,441 9/2/2020
8.1.7 1,310 8/28/2020
8.1.4 1,321 8/25/2020
8.1.3 1,495 8/18/2020
8.1.2 1,296 8/16/2020
8.1.1 1,358 8/15/2020
8.0.3 1,375 8/11/2020
8.0.2 1,405 8/7/2020
8.0.1 1,400 8/7/2020
8.0.0 1,343 8/7/2020
7.0.1 1,458 6/28/2020
7.0.0 1,457 6/28/2020
5.0.10 1,428 5/31/2020
5.0.9 1,529 5/30/2020
5.0.8 1,392 5/29/2020
5.0.7 1,385 5/29/2020
5.0.5 1,459 2/27/2020
5.0.4 1,422 2/26/2020
5.0.3 1,411 2/26/2020
5.0.2 1,419 2/25/2020
5.0.1 1,322 2/25/2020
5.0.0 1,449 2/25/2020
4.1.5 1,386 2/23/2020
4.1.4 1,468 2/23/2020
4.1.3 1,399 2/22/2020
4.1.2 1,398 2/22/2020
4.1.1 1,384 2/21/2020
4.1.0 1,426 2/21/2020
4.0.9 1,507 2/7/2020
4.0.8 1,347 2/7/2020
4.0.7 1,366 2/7/2020
4.0.5 1,382 1/28/2020
4.0.4 1,512 1/27/2020
4.0.3 1,361 1/27/2020
4.0.2 1,510 1/16/2020
4.0.1 1,525 1/11/2020
4.0.0 1,476 1/5/2020
3.1.7 1,524 12/17/2019
3.1.6 1,422 12/12/2019
3.1.5 1,418 12/12/2019
3.1.4 1,424 12/5/2019
3.1.3 1,458 12/4/2019
3.1.2 1,489 11/30/2019
3.1.1 1,640 11/26/2019
3.1.0 1,454 11/10/2019
3.0.4 1,289 11/1/2019
3.0.3 1,454 10/28/2019
3.0.2 1,468 10/28/2019
3.0.1 1,466 10/26/2019
3.0.0 1,285 10/23/2019
2.1.4 1,090 10/21/2019
2.1.3 1,420 10/21/2019
2.1.2 1,561 10/21/2019
2.1.1 1,433 10/19/2019
2.1.0 1,484 10/19/2019
2.0.9 1,183 10/18/2019
2.0.8 1,442 10/18/2019
2.0.7 1,186 10/18/2019
2.0.6 1,174 10/18/2019
2.0.5 1,223 10/18/2019
2.0.4 1,182 10/17/2019
2.0.3 1,319 10/16/2019
2.0.2 1,309 10/15/2019
2.0.1 1,343 10/14/2019
2.0.0 1,185 10/13/2019
1.1.7 1,529 10/11/2019
1.1.6 1,471 10/11/2019