magic.library 13.3.8

.NET 6.0
Install-Package magic.library -Version 13.3.8
dotnet add package magic.library --version 13.3.8
<PackageReference Include="magic.library" Version="13.3.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.library --version 13.3.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: magic.library, 13.3.8"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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=13.3.8

// Install magic.library as a Cake Tool
#tool nuget:?package=magic.library&version=13.3.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Wiring all parts of Magic together automagically

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

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.

Quality gates

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
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
13.3.8 58 5/19/2022
13.3.7 40 5/18/2022
13.3.6 96 5/14/2022
13.3.4 194 5/9/2022
13.3.1 150 5/1/2022
13.3.0 63 5/1/2022
13.2.2 144 4/25/2022
13.2.1 73 4/25/2022
13.2.0 119 4/21/2022
13.1.1 104 4/20/2022
13.1.0 196 4/7/2022
13.0.0 132 4/5/2022
12.0.3 258 3/14/2022
11.0.7 119 3/11/2022
11.0.5 200 3/2/2022
11.0.4 162 2/22/2022
11.0.3 172 2/9/2022
11.0.2 195 2/6/2022
11.0.1 166 2/5/2022
10.0.21 175 1/28/2022
10.0.20 193 1/27/2022
10.0.19 168 1/23/2022
10.0.18 141 1/17/2022
10.0.17 164 1/14/2022
10.0.16 197 1/2/2022
10.0.15 265 12/31/2021
10.0.14 281 12/28/2021
10.0.13 339 12/23/2021
10.0.11 180 12/23/2021
10.0.10 194 12/22/2021
10.0.9 317 12/22/2021
10.0.8 211 12/22/2021
10.0.7 310 12/22/2021
10.0.6 279 12/19/2021
10.0.5 326 12/18/2021
10.0.3 156 12/16/2021
10.0.2 224 12/14/2021
10.0.1 140 12/13/2021
10.0.0 195 12/6/2021
9.9.9 945 11/29/2021
9.9.6 4,434 11/24/2021
9.9.5 160 11/23/2021
9.9.4 478 11/21/2021
9.9.3 227 11/9/2021
9.9.2 266 11/4/2021
9.9.0 366 10/30/2021
9.8.9 342 10/29/2021
9.8.7 282 10/27/2021
9.8.6 275 10/27/2021
9.8.5 334 10/26/2021
9.8.4 320 10/25/2021
9.8.3 353 10/24/2021
9.8.1 272 10/21/2021
9.8.0 360 10/20/2021
9.7.9 281 10/20/2021
9.7.8 273 10/19/2021
9.7.7 495 10/17/2021
9.7.6 416 10/17/2021
9.7.5 296 10/14/2021
9.7.1 239 10/14/2021
9.7.0 317 10/9/2021
9.6.8 298 8/30/2021
9.6.7 273 8/26/2021
9.6.6 413 8/14/2021
9.6.5 475 8/11/2021
9.6.4 311 8/10/2021
9.6.3 321 8/9/2021
9.6.2 286 8/8/2021
9.6.1 267 8/8/2021
9.5.9 364 8/5/2021
9.5.8 380 8/4/2021
9.5.3 319 7/20/2021
9.5.0 580 7/9/2021
9.4.5 330 6/29/2021
9.4.4 410 6/29/2021
9.4.0 282 6/24/2021
9.3.7 311 6/21/2021
9.3.6 353 6/21/2021
9.3.5 455 6/18/2021
9.3.4 365 6/18/2021
9.2.5 474 6/7/2021
9.2.4 380 6/6/2021
9.2.3 334 6/6/2021
9.2.2 273 6/4/2021
9.2.1 494 6/1/2021
9.2.0 404 5/26/2021
9.1.9 259 5/5/2021
9.1.8 396 5/5/2021
9.1.7 264 5/3/2021
9.1.4 283 4/21/2021
9.1.2 270 4/18/2021
9.1.1 235 4/15/2021
9.1.0 283 4/14/2021
9.0.1 344 4/12/2021
9.0.0 291 4/5/2021
8.9.92 605 3/30/2021
8.9.4 643 3/26/2021
8.9.3 625 3/19/2021
8.9.2 591 1/29/2021
8.9.1 661 1/24/2021
8.9.0 696 1/22/2021
8.7.1 1,004 11/15/2020
8.7.0 701 11/15/2020
8.6.9 657 11/8/2020
8.6.7 639 11/4/2020
8.6.6 695 11/2/2020
8.6.5 649 11/1/2020
8.6.3 701 10/30/2020
8.6.2 611 10/30/2020
8.6.1 673 10/29/2020
8.6.0 602 10/28/2020
8.5.1 620 10/26/2020
8.5.0 614 10/23/2020
8.4.6 784 10/20/2020
8.4.5 645 10/18/2020
8.4.4 685 10/17/2020
8.4.3 644 10/16/2020
8.4.2 643 10/16/2020
8.4.1 633 10/15/2020
8.4.0 725 10/13/2020
8.3.3 636 10/11/2020
8.3.2 685 10/8/2020
8.3.1 694 10/5/2020
8.3.0 683 10/3/2020
8.2.3 603 10/1/2020
8.2.2 842 9/26/2020
8.2.1 707 9/25/2020
8.2.0 758 9/25/2020
8.1.25 654 9/24/2020
8.1.24 681 9/23/2020
8.1.23 640 9/23/2020
8.1.22 680 9/21/2020
8.1.21 726 9/15/2020
8.1.20 717 9/14/2020
8.1.19 667 9/13/2020
8.1.18 679 9/13/2020
8.1.17 710 9/13/2020
8.1.16 709 9/13/2020
8.1.15 645 9/12/2020
8.1.13 561 9/11/2020
8.1.12 662 9/11/2020
8.1.11 663 9/11/2020
8.1.10 703 9/6/2020
8.1.9 710 9/3/2020
8.1.8 735 9/2/2020
8.1.7 607 8/28/2020
8.1.4 595 8/25/2020
8.1.3 748 8/18/2020
8.1.2 594 8/16/2020
8.1.1 701 8/15/2020
8.0.3 667 8/11/2020
8.0.2 695 8/7/2020
8.0.1 666 8/7/2020
8.0.0 638 8/7/2020
7.0.1 749 6/28/2020
7.0.0 746 6/28/2020
5.0.10 705 5/31/2020
5.0.9 755 5/30/2020
5.0.8 683 5/29/2020
5.0.7 675 5/29/2020
5.0.5 773 2/27/2020
5.0.4 698 2/26/2020
5.0.3 708 2/26/2020
5.0.2 722 2/25/2020
5.0.1 614 2/25/2020
5.0.0 717 2/25/2020
4.1.5 676 2/23/2020
4.1.4 763 2/23/2020
4.1.3 697 2/22/2020
4.1.2 713 2/22/2020
4.1.1 681 2/21/2020
4.1.0 705 2/21/2020
4.0.9 770 2/7/2020
4.0.8 633 2/7/2020
4.0.7 653 2/7/2020
4.0.5 700 1/28/2020
4.0.4 766 1/27/2020
4.0.3 714 1/27/2020
4.0.2 770 1/16/2020
4.0.1 790 1/11/2020
4.0.0 749 1/5/2020
3.1.7 811 12/17/2019
3.1.6 735 12/12/2019
3.1.5 691 12/12/2019
3.1.4 733 12/5/2019
3.1.3 735 12/4/2019
3.1.2 760 11/30/2019
3.1.1 922 11/26/2019
3.1.0 749 11/10/2019
3.0.4 749 11/1/2019
3.0.3 724 10/28/2019
3.0.2 729 10/28/2019
3.0.1 738 10/26/2019
3.0.0 634 10/23/2019
2.1.4 603 10/21/2019
2.1.3 701 10/21/2019
2.1.2 789 10/21/2019
2.1.1 684 10/19/2019
2.1.0 753 10/19/2019
2.0.9 670 10/18/2019
2.0.8 736 10/18/2019
2.0.7 679 10/18/2019
2.0.6 655 10/18/2019
2.0.5 702 10/18/2019
2.0.4 677 10/17/2019
2.0.3 641 10/16/2019
2.0.2 656 10/15/2019
2.0.1 641 10/14/2019
2.0.0 599 10/13/2019
1.1.7 749 10/11/2019
1.1.6 729 10/11/2019