magic.library 13.4.25

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.library --version 13.4.25                
NuGet\Install-Package magic.library -Version 13.4.25                
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="13.4.25" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.library --version 13.4.25                
#r "nuget: magic.library, 13.4.25"                
#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=13.4.25

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

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 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.  net8.0 was computed.  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. 
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 267 2/17/2024
17.3.7 154 2/12/2024
17.3.6 122 2/12/2024
17.3.5 116 2/10/2024
17.3.4 114 2/9/2024
17.3.3 116 2/8/2024
17.3.2 124 2/2/2024
17.3.1 129 1/30/2024
17.2.2 99 1/30/2024
17.2.1 140 1/22/2024
17.2.0 116 1/22/2024
17.1.7 181 1/12/2024
17.1.6 149 1/11/2024
17.1.5 156 1/5/2024
17.0.1 213 1/1/2024
17.0.0 342 12/14/2023
16.11.6 243 11/14/2023
16.11.5 185 11/12/2023
16.9.0 305 10/9/2023
16.8.5 187 9/30/2023
16.8.4 180 9/25/2023
16.8.0 152 9/24/2023
16.7.51 146 9/24/2023
16.7.50 156 9/23/2023
16.7.1 202 9/4/2023
16.7.0 311 7/11/2023
16.6.13 201 7/6/2023
16.6.12 198 7/5/2023
16.6.11 186 7/5/2023
16.6.5 224 7/3/2023
16.4.4 224 7/2/2023
16.4.3 233 6/27/2023
16.4.2 225 6/25/2023
16.4.1 225 6/25/2023
16.4.0 211 6/22/2023
16.3.2 302 6/7/2023
16.3.0 310 5/28/2023
16.2.0 390 5/13/2023
16.1.10 370 5/1/2023
16.1.9 289 4/30/2023
16.1.1 310 4/20/2023
15.10.11 332 4/16/2023
15.9.40 365 4/3/2023
15.9.1 421 3/27/2023
15.9.0 426 3/24/2023
15.8.2 466 3/20/2023
15.7.0 348 3/6/2023
15.5.20 716 2/23/2023
15.5.13 517 2/13/2023
15.5.9 410 2/11/2023
15.5.2 491 2/5/2023
15.5.1 405 2/3/2023
15.5.0 480 1/28/2023
15.2.0 624 1/18/2023
15.1.0 1,092 12/28/2022
14.5.7 634 12/13/2022
14.5.5 733 12/6/2022
14.5.1 569 11/23/2022
14.5.0 513 11/18/2022
14.4.5 589 10/22/2022
14.4.2 517 10/22/2022
14.4.1 522 10/22/2022
14.4.0 557 10/17/2022
14.3.9 575 10/13/2022
14.3.6 578 10/7/2022
14.3.2 587 9/18/2022
14.3.1 667 9/12/2022
14.3.0 562 9/10/2022
14.1.3 822 8/7/2022
14.1.2 574 8/7/2022
14.1.1 580 8/7/2022
14.0.14 572 7/26/2022
14.0.12 562 7/24/2022
14.0.11 538 7/23/2022
14.0.10 559 7/23/2022
14.0.9 540 7/23/2022
14.0.8 630 7/17/2022
14.0.5 698 7/11/2022
14.0.4 630 7/7/2022
14.0.3 624 7/2/2022
14.0.2 567 7/2/2022
14.0.1 612 7/2/2022
14.0.0 592 6/25/2022
13.4.28 584 6/11/2022
13.4.25 696 6/9/2022
13.4.24 586 6/9/2022
13.4.19 638 6/8/2022
13.4.3 614 6/6/2022
13.4.2 653 6/4/2022
13.4.0 673 5/31/2022
13.3.8 645 5/19/2022
13.3.7 604 5/18/2022
13.3.6 647 5/14/2022
13.3.4 721 5/9/2022
13.3.1 656 5/1/2022
13.3.0 616 5/1/2022
13.2.2 672 4/25/2022
13.2.1 629 4/25/2022
13.2.0 658 4/21/2022
13.1.1 677 4/20/2022
13.1.0 752 4/7/2022
13.0.0 688 4/5/2022
12.0.3 851 3/14/2022
11.0.7 728 3/11/2022
11.0.5 784 3/2/2022
11.0.4 703 2/22/2022
11.0.3 704 2/9/2022
11.0.2 761 2/6/2022
11.0.1 751 2/5/2022
10.0.21 717 1/28/2022
10.0.20 735 1/27/2022
10.0.19 722 1/23/2022
10.0.18 690 1/17/2022
10.0.17 701 1/14/2022
10.0.16 551 1/2/2022
10.0.15 608 12/31/2021
10.0.14 620 12/28/2021
10.0.13 690 12/23/2021
10.0.11 481 12/23/2021
10.0.10 500 12/22/2021
10.0.9 658 12/22/2021
10.0.8 549 12/22/2021
10.0.7 701 12/22/2021
10.0.6 584 12/19/2021
10.0.5 679 12/18/2021
10.0.3 463 12/16/2021
10.0.2 542 12/14/2021
10.0.1 434 12/13/2021
10.0.0 479 12/6/2021
9.9.9 1,265 11/29/2021
9.9.6 4,736 11/24/2021
9.9.5 483 11/23/2021
9.9.4 781 11/21/2021
9.9.3 554 11/9/2021
9.9.2 570 11/4/2021
9.9.0 670 10/30/2021
9.8.9 695 10/29/2021
9.8.7 579 10/27/2021
9.8.6 587 10/27/2021
9.8.5 679 10/26/2021
9.8.4 652 10/25/2021
9.8.3 705 10/24/2021
9.8.1 576 10/21/2021
9.8.0 651 10/20/2021
9.7.9 565 10/20/2021
9.7.8 598 10/19/2021
9.7.7 832 10/17/2021
9.7.6 728 10/17/2021
9.7.5 603 10/14/2021
9.7.1 541 10/14/2021
9.7.0 617 10/9/2021
9.6.8 627 8/30/2021
9.6.7 604 8/26/2021
9.6.6 716 8/14/2021
9.6.5 820 8/11/2021
9.6.4 615 8/10/2021
9.6.3 605 8/9/2021
9.6.2 604 8/8/2021
9.6.1 562 8/8/2021
9.5.9 759 8/5/2021
9.5.8 755 8/4/2021
9.5.3 640 7/20/2021
9.5.0 1,006 7/9/2021
9.4.5 615 6/29/2021
9.4.4 763 6/29/2021
9.4.0 606 6/24/2021
9.3.7 616 6/21/2021
9.3.6 666 6/21/2021
9.3.5 794 6/18/2021
9.3.4 724 6/18/2021
9.2.5 773 6/7/2021
9.2.4 711 6/6/2021
9.2.3 647 6/6/2021
9.2.2 556 6/4/2021
9.2.1 791 6/1/2021
9.2.0 749 5/26/2021
9.1.9 566 5/5/2021
9.1.8 717 5/5/2021
9.1.7 574 5/3/2021
9.1.4 583 4/21/2021
9.1.2 571 4/18/2021
9.1.1 554 4/15/2021
9.1.0 610 4/14/2021
9.0.1 674 4/12/2021
9.0.0 571 4/5/2021
8.9.92 1,148 3/30/2021
8.9.4 1,156 3/26/2021
8.9.3 1,200 3/19/2021
8.9.2 1,179 1/29/2021
8.9.1 1,248 1/24/2021
8.9.0 1,312 1/22/2021
8.7.1 1,613 11/15/2020
8.7.0 1,316 11/15/2020
8.6.9 1,253 11/8/2020
8.6.7 1,225 11/4/2020
8.6.6 1,310 11/2/2020
8.6.5 1,290 11/1/2020
8.6.3 1,313 10/30/2020
8.6.2 1,215 10/30/2020
8.6.1 1,306 10/29/2020
8.6.0 1,265 10/28/2020
8.5.1 1,255 10/26/2020
8.5.0 1,204 10/23/2020
8.4.6 1,423 10/20/2020
8.4.5 1,306 10/18/2020
8.4.4 1,327 10/17/2020
8.4.3 1,294 10/16/2020
8.4.2 1,245 10/16/2020
8.4.1 1,241 10/15/2020
8.4.0 1,318 10/13/2020
8.3.3 1,242 10/11/2020
8.3.2 1,285 10/8/2020
8.3.1 1,304 10/5/2020
8.3.0 1,254 10/3/2020
8.2.3 1,211 10/1/2020
8.2.2 1,491 9/26/2020
8.2.1 1,351 9/25/2020
8.2.0 1,385 9/25/2020
8.1.25 1,281 9/24/2020
8.1.24 1,276 9/23/2020
8.1.23 1,202 9/23/2020
8.1.22 1,275 9/21/2020
8.1.21 1,326 9/15/2020
8.1.20 1,335 9/14/2020
8.1.19 1,312 9/13/2020
8.1.18 1,280 9/13/2020
8.1.17 1,330 9/13/2020
8.1.16 1,329 9/13/2020
8.1.15 1,254 9/12/2020
8.1.13 1,149 9/11/2020
8.1.12 1,273 9/11/2020
8.1.11 1,276 9/11/2020
8.1.10 1,321 9/6/2020
8.1.9 1,319 9/3/2020
8.1.8 1,343 9/2/2020
8.1.7 1,213 8/28/2020
8.1.4 1,214 8/25/2020
8.1.3 1,385 8/18/2020
8.1.2 1,202 8/16/2020
8.1.1 1,264 8/15/2020
8.0.3 1,278 8/11/2020
8.0.2 1,300 8/7/2020
8.0.1 1,303 8/7/2020
8.0.0 1,248 8/7/2020
7.0.1 1,359 6/28/2020
7.0.0 1,351 6/28/2020
5.0.10 1,320 5/31/2020
5.0.9 1,419 5/30/2020
5.0.8 1,297 5/29/2020
5.0.7 1,264 5/29/2020
5.0.5 1,355 2/27/2020
5.0.4 1,324 2/26/2020
5.0.3 1,315 2/26/2020
5.0.2 1,321 2/25/2020
5.0.1 1,224 2/25/2020
5.0.0 1,342 2/25/2020
4.1.5 1,283 2/23/2020
4.1.4 1,366 2/23/2020
4.1.3 1,301 2/22/2020
4.1.2 1,294 2/22/2020
4.1.1 1,286 2/21/2020
4.1.0 1,317 2/21/2020
4.0.9 1,407 2/7/2020
4.0.8 1,241 2/7/2020
4.0.7 1,264 2/7/2020
4.0.5 1,277 1/28/2020
4.0.4 1,409 1/27/2020
4.0.3 1,261 1/27/2020
4.0.2 1,404 1/16/2020
4.0.1 1,426 1/11/2020
4.0.0 1,375 1/5/2020
3.1.7 1,425 12/17/2019
3.1.6 1,314 12/12/2019
3.1.5 1,310 12/12/2019
3.1.4 1,324 12/5/2019
3.1.3 1,359 12/4/2019
3.1.2 1,382 11/30/2019
3.1.1 1,543 11/26/2019
3.1.0 1,343 11/10/2019
3.0.4 1,184 11/1/2019
3.0.3 1,350 10/28/2019
3.0.2 1,364 10/28/2019
3.0.1 1,355 10/26/2019
3.0.0 1,183 10/23/2019
2.1.4 980 10/21/2019
2.1.3 1,316 10/21/2019
2.1.2 1,447 10/21/2019
2.1.1 1,322 10/19/2019
2.1.0 1,372 10/19/2019
2.0.9 1,069 10/18/2019
2.0.8 1,340 10/18/2019
2.0.7 1,077 10/18/2019
2.0.6 1,066 10/18/2019
2.0.5 1,121 10/18/2019
2.0.4 1,080 10/17/2019
2.0.3 1,213 10/16/2019
2.0.2 1,197 10/15/2019
2.0.1 1,240 10/14/2019
2.0.0 1,076 10/13/2019
1.1.7 1,408 10/11/2019
1.1.6 1,356 10/11/2019