magic.library 14.1.3

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

// Install magic.library as a Cake Tool
#tool nuget:?package=magic.library&version=14.1.3
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
14.1.3 71 8/7/2022
14.1.2 54 8/7/2022
14.1.1 51 8/7/2022
14.0.14 89 7/26/2022
14.0.12 74 7/24/2022
14.0.11 58 7/23/2022
14.0.10 51 7/23/2022
14.0.9 49 7/23/2022
14.0.8 133 7/17/2022
14.0.5 201 7/11/2022
14.0.4 150 7/7/2022
14.0.3 116 7/2/2022
14.0.2 80 7/2/2022
14.0.1 90 7/2/2022
14.0.0 94 6/25/2022
13.4.28 90 6/11/2022
13.4.25 203 6/9/2022
13.4.24 101 6/9/2022
13.4.19 145 6/8/2022
13.4.3 109 6/6/2022
13.4.2 159 6/4/2022
13.4.0 180 5/31/2022
13.3.8 150 5/19/2022
13.3.7 96 5/18/2022
13.3.6 157 5/14/2022
13.3.4 243 5/9/2022
13.3.1 193 5/1/2022
13.3.0 119 5/1/2022
13.2.2 185 4/25/2022
13.2.1 130 4/25/2022
13.2.0 169 4/21/2022
13.1.1 171 4/20/2022
13.1.0 242 4/7/2022
13.0.0 186 4/5/2022
12.0.3 309 3/14/2022
11.0.7 175 3/11/2022
11.0.5 241 3/2/2022
11.0.4 217 2/22/2022
11.0.3 230 2/9/2022
11.0.2 243 2/6/2022
11.0.1 232 2/5/2022
10.0.21 217 1/28/2022
10.0.20 229 1/27/2022
10.0.19 213 1/23/2022
10.0.18 182 1/17/2022
10.0.17 201 1/14/2022
10.0.16 245 1/2/2022
10.0.15 318 12/31/2021
10.0.14 328 12/28/2021
10.0.13 390 12/23/2021
10.0.11 209 12/23/2021
10.0.10 219 12/22/2021
10.0.9 362 12/22/2021
10.0.8 239 12/22/2021
10.0.7 353 12/22/2021
10.0.6 309 12/19/2021
10.0.5 377 12/18/2021
10.0.3 181 12/16/2021
10.0.2 247 12/14/2021
10.0.1 171 12/13/2021
10.0.0 216 12/6/2021
9.9.9 968 11/29/2021
9.9.6 4,457 11/24/2021
9.9.5 186 11/23/2021
9.9.4 501 11/21/2021
9.9.3 244 11/9/2021
9.9.2 281 11/4/2021
9.9.0 397 10/30/2021
9.8.9 382 10/29/2021
9.8.7 310 10/27/2021
9.8.6 299 10/27/2021
9.8.5 374 10/26/2021
9.8.4 347 10/25/2021
9.8.3 405 10/24/2021
9.8.1 301 10/21/2021
9.8.0 384 10/20/2021
9.7.9 306 10/20/2021
9.7.8 295 10/19/2021
9.7.7 521 10/17/2021
9.7.6 443 10/17/2021
9.7.5 313 10/14/2021
9.7.1 266 10/14/2021
9.7.0 334 10/9/2021
9.6.8 326 8/30/2021
9.6.7 292 8/26/2021
9.6.6 439 8/14/2021
9.6.5 511 8/11/2021
9.6.4 336 8/10/2021
9.6.3 342 8/9/2021
9.6.2 313 8/8/2021
9.6.1 291 8/8/2021
9.5.9 413 8/5/2021
9.5.8 423 8/4/2021
9.5.3 343 7/20/2021
9.5.0 628 7/9/2021
9.4.5 357 6/29/2021
9.4.4 454 6/29/2021
9.4.0 303 6/24/2021
9.3.7 330 6/21/2021
9.3.6 381 6/21/2021
9.3.5 491 6/18/2021
9.3.4 399 6/18/2021
9.2.5 495 6/7/2021
9.2.4 411 6/6/2021
9.2.3 357 6/6/2021
9.2.2 302 6/4/2021
9.2.1 511 6/1/2021
9.2.0 451 5/26/2021
9.1.9 279 5/5/2021
9.1.8 423 5/5/2021
9.1.7 283 5/3/2021
9.1.4 310 4/21/2021
9.1.2 295 4/18/2021
9.1.1 259 4/15/2021
9.1.0 313 4/14/2021
9.0.1 377 4/12/2021
9.0.0 317 4/5/2021
8.9.92 643 3/30/2021
8.9.4 667 3/26/2021
8.9.3 678 3/19/2021
8.9.2 622 1/29/2021
8.9.1 702 1/24/2021
8.9.0 753 1/22/2021
8.7.1 1,067 11/15/2020
8.7.0 751 11/15/2020
8.6.9 709 11/8/2020
8.6.7 685 11/4/2020
8.6.6 737 11/2/2020
8.6.5 700 11/1/2020
8.6.3 741 10/30/2020
8.6.2 662 10/30/2020
8.6.1 746 10/29/2020
8.6.0 662 10/28/2020
8.5.1 670 10/26/2020
8.5.0 657 10/23/2020
8.4.6 855 10/20/2020
8.4.5 707 10/18/2020
8.4.4 740 10/17/2020
8.4.3 699 10/16/2020
8.4.2 689 10/16/2020
8.4.1 678 10/15/2020
8.4.0 760 10/13/2020
8.3.3 684 10/11/2020
8.3.2 740 10/8/2020
8.3.1 743 10/5/2020
8.3.0 728 10/3/2020
8.2.3 645 10/1/2020
8.2.2 891 9/26/2020
8.2.1 760 9/25/2020
8.2.0 807 9/25/2020
8.1.25 700 9/24/2020
8.1.24 732 9/23/2020
8.1.23 679 9/23/2020
8.1.22 722 9/21/2020
8.1.21 780 9/15/2020
8.1.20 770 9/14/2020
8.1.19 722 9/13/2020
8.1.18 721 9/13/2020
8.1.17 764 9/13/2020
8.1.16 770 9/13/2020
8.1.15 699 9/12/2020
8.1.13 613 9/11/2020
8.1.12 718 9/11/2020
8.1.11 721 9/11/2020
8.1.10 760 9/6/2020
8.1.9 749 9/3/2020
8.1.8 788 9/2/2020
8.1.7 640 8/28/2020
8.1.4 655 8/25/2020
8.1.3 786 8/18/2020
8.1.2 637 8/16/2020
8.1.1 723 8/15/2020
8.0.3 715 8/11/2020
8.0.2 729 8/7/2020
8.0.1 699 8/7/2020
8.0.0 690 8/7/2020
7.0.1 789 6/28/2020
7.0.0 791 6/28/2020
5.0.10 758 5/31/2020
5.0.9 816 5/30/2020
5.0.8 724 5/29/2020
5.0.7 715 5/29/2020
5.0.5 818 2/27/2020
5.0.4 753 2/26/2020
5.0.3 750 2/26/2020
5.0.2 761 2/25/2020
5.0.1 662 2/25/2020
5.0.0 770 2/25/2020
4.1.5 731 2/23/2020
4.1.4 822 2/23/2020
4.1.3 754 2/22/2020
4.1.2 752 2/22/2020
4.1.1 743 2/21/2020
4.1.0 747 2/21/2020
4.0.9 816 2/7/2020
4.0.8 669 2/7/2020
4.0.7 701 2/7/2020
4.0.5 727 1/28/2020
4.0.4 824 1/27/2020
4.0.3 742 1/27/2020
4.0.2 819 1/16/2020
4.0.1 834 1/11/2020
4.0.0 795 1/5/2020
3.1.7 860 12/17/2019
3.1.6 792 12/12/2019
3.1.5 744 12/12/2019
3.1.4 781 12/5/2019
3.1.3 789 12/4/2019
3.1.2 813 11/30/2019
3.1.1 961 11/26/2019
3.1.0 798 11/10/2019
3.0.4 810 11/1/2019
3.0.3 766 10/28/2019
3.0.2 799 10/28/2019
3.0.1 789 10/26/2019
3.0.0 665 10/23/2019
2.1.4 641 10/21/2019
2.1.3 751 10/21/2019
2.1.2 839 10/21/2019
2.1.1 726 10/19/2019
2.1.0 794 10/19/2019
2.0.9 713 10/18/2019
2.0.8 786 10/18/2019
2.0.7 730 10/18/2019
2.0.6 716 10/18/2019
2.0.5 754 10/18/2019
2.0.4 723 10/17/2019
2.0.3 665 10/16/2019
2.0.2 684 10/15/2019
2.0.1 684 10/14/2019
2.0.0 622 10/13/2019
1.1.7 799 10/11/2019
1.1.6 773 10/11/2019