magic.library 14.3.2

.NET 6.0
NuGet\Install-Package magic.library -Version 14.3.2
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.
dotnet add package magic.library --version 14.3.2
<PackageReference Include="magic.library" Version="14.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.library --version 14.3.2
#r "nuget: magic.library, 14.3.2"
#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.3.2

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

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.3.2 37 9/18/2022
14.3.1 176 9/12/2022
14.3.0 53 9/10/2022
14.1.3 335 8/7/2022
14.1.2 85 8/7/2022
14.1.1 79 8/7/2022
14.0.14 118 7/26/2022
14.0.12 107 7/24/2022
14.0.11 88 7/23/2022
14.0.10 92 7/23/2022
14.0.9 91 7/23/2022
14.0.8 172 7/17/2022
14.0.5 233 7/11/2022
14.0.4 180 7/7/2022
14.0.3 148 7/2/2022
14.0.2 105 7/2/2022
14.0.1 129 7/2/2022
14.0.0 119 6/25/2022
13.4.28 114 6/11/2022
13.4.25 234 6/9/2022
13.4.24 135 6/9/2022
13.4.19 177 6/8/2022
13.4.3 134 6/6/2022
13.4.2 190 6/4/2022
13.4.0 205 5/31/2022
13.3.8 181 5/19/2022
13.3.7 131 5/18/2022
13.3.6 180 5/14/2022
13.3.4 270 5/9/2022
13.3.1 225 5/1/2022
13.3.0 148 5/1/2022
13.2.2 208 4/25/2022
13.2.1 156 4/25/2022
13.2.0 205 4/21/2022
13.1.1 203 4/20/2022
13.1.0 271 4/7/2022
13.0.0 214 4/5/2022
12.0.3 338 3/14/2022
11.0.7 205 3/11/2022
11.0.5 267 3/2/2022
11.0.4 238 2/22/2022
11.0.3 252 2/9/2022
11.0.2 273 2/6/2022
11.0.1 260 2/5/2022
10.0.21 235 1/28/2022
10.0.20 248 1/27/2022
10.0.19 230 1/23/2022
10.0.18 206 1/17/2022
10.0.17 222 1/14/2022
10.0.16 255 1/2/2022
10.0.15 335 12/31/2021
10.0.14 343 12/28/2021
10.0.13 405 12/23/2021
10.0.11 225 12/23/2021
10.0.10 234 12/22/2021
10.0.9 378 12/22/2021
10.0.8 252 12/22/2021
10.0.7 372 12/22/2021
10.0.6 318 12/19/2021
10.0.5 389 12/18/2021
10.0.3 197 12/16/2021
10.0.2 269 12/14/2021
10.0.1 191 12/13/2021
10.0.0 235 12/6/2021
9.9.9 982 11/29/2021
9.9.6 4,474 11/24/2021
9.9.5 210 11/23/2021
9.9.4 524 11/21/2021
9.9.3 266 11/9/2021
9.9.2 300 11/4/2021
9.9.0 420 10/30/2021
9.8.9 407 10/29/2021
9.8.7 337 10/27/2021
9.8.6 323 10/27/2021
9.8.5 399 10/26/2021
9.8.4 363 10/25/2021
9.8.3 427 10/24/2021
9.8.1 320 10/21/2021
9.8.0 400 10/20/2021
9.7.9 329 10/20/2021
9.7.8 312 10/19/2021
9.7.7 538 10/17/2021
9.7.6 460 10/17/2021
9.7.5 331 10/14/2021
9.7.1 288 10/14/2021
9.7.0 350 10/9/2021
9.6.8 344 8/30/2021
9.6.7 318 8/26/2021
9.6.6 465 8/14/2021
9.6.5 537 8/11/2021
9.6.4 353 8/10/2021
9.6.3 362 8/9/2021
9.6.2 333 8/8/2021
9.6.1 304 8/8/2021
9.5.9 442 8/5/2021
9.5.8 446 8/4/2021
9.5.3 350 7/20/2021
9.5.0 641 7/9/2021
9.4.5 376 6/29/2021
9.4.4 474 6/29/2021
9.4.0 321 6/24/2021
9.3.7 345 6/21/2021
9.3.6 396 6/21/2021
9.3.5 505 6/18/2021
9.3.4 412 6/18/2021
9.2.5 512 6/7/2021
9.2.4 425 6/6/2021
9.2.3 371 6/6/2021
9.2.2 323 6/4/2021
9.2.1 538 6/1/2021
9.2.0 482 5/26/2021
9.1.9 304 5/5/2021
9.1.8 447 5/5/2021
9.1.7 301 5/3/2021
9.1.4 327 4/21/2021
9.1.2 311 4/18/2021
9.1.1 280 4/15/2021
9.1.0 332 4/14/2021
9.0.1 402 4/12/2021
9.0.0 336 4/5/2021
8.9.92 670 3/30/2021
8.9.4 704 3/26/2021
8.9.3 706 3/19/2021
8.9.2 665 1/29/2021
8.9.1 736 1/24/2021
8.9.0 789 1/22/2021
8.7.1 1,098 11/15/2020
8.7.0 782 11/15/2020
8.6.9 737 11/8/2020
8.6.7 710 11/4/2020
8.6.6 770 11/2/2020
8.6.5 733 11/1/2020
8.6.3 770 10/30/2020
8.6.2 691 10/30/2020
8.6.1 770 10/29/2020
8.6.0 696 10/28/2020
8.5.1 701 10/26/2020
8.5.0 685 10/23/2020
8.4.6 887 10/20/2020
8.4.5 730 10/18/2020
8.4.4 767 10/17/2020
8.4.3 727 10/16/2020
8.4.2 716 10/16/2020
8.4.1 700 10/15/2020
8.4.0 782 10/13/2020
8.3.3 710 10/11/2020
8.3.2 766 10/8/2020
8.3.1 770 10/5/2020
8.3.0 751 10/3/2020
8.2.3 680 10/1/2020
8.2.2 924 9/26/2020
8.2.1 791 9/25/2020
8.2.0 843 9/25/2020
8.1.25 727 9/24/2020
8.1.24 766 9/23/2020
8.1.23 709 9/23/2020
8.1.22 756 9/21/2020
8.1.21 806 9/15/2020
8.1.20 805 9/14/2020
8.1.19 756 9/13/2020
8.1.18 747 9/13/2020
8.1.17 784 9/13/2020
8.1.16 794 9/13/2020
8.1.15 725 9/12/2020
8.1.13 631 9/11/2020
8.1.12 745 9/11/2020
8.1.11 739 9/11/2020
8.1.10 779 9/6/2020
8.1.9 773 9/3/2020
8.1.8 815 9/2/2020
8.1.7 656 8/28/2020
8.1.4 679 8/25/2020
8.1.3 809 8/18/2020
8.1.2 665 8/16/2020
8.1.1 746 8/15/2020
8.0.3 744 8/11/2020
8.0.2 755 8/7/2020
8.0.1 730 8/7/2020
8.0.0 714 8/7/2020
7.0.1 814 6/28/2020
7.0.0 818 6/28/2020
5.0.10 786 5/31/2020
5.0.9 836 5/30/2020
5.0.8 745 5/29/2020
5.0.7 735 5/29/2020
5.0.5 843 2/27/2020
5.0.4 773 2/26/2020
5.0.3 778 2/26/2020
5.0.2 783 2/25/2020
5.0.1 684 2/25/2020
5.0.0 792 2/25/2020
4.1.5 756 2/23/2020
4.1.4 840 2/23/2020
4.1.3 779 2/22/2020
4.1.2 776 2/22/2020
4.1.1 763 2/21/2020
4.1.0 772 2/21/2020
4.0.9 838 2/7/2020
4.0.8 690 2/7/2020
4.0.7 723 2/7/2020
4.0.5 754 1/28/2020
4.0.4 854 1/27/2020
4.0.3 772 1/27/2020
4.0.2 844 1/16/2020
4.0.1 863 1/11/2020
4.0.0 821 1/5/2020
3.1.7 892 12/17/2019
3.1.6 821 12/12/2019
3.1.5 770 12/12/2019
3.1.4 803 12/5/2019
3.1.3 818 12/4/2019
3.1.2 838 11/30/2019
3.1.1 992 11/26/2019
3.1.0 819 11/10/2019
3.0.4 828 11/1/2019
3.0.3 790 10/28/2019
3.0.2 828 10/28/2019
3.0.1 817 10/26/2019
3.0.0 693 10/23/2019
2.1.4 660 10/21/2019
2.1.3 783 10/21/2019
2.1.2 870 10/21/2019
2.1.1 750 10/19/2019
2.1.0 824 10/19/2019
2.0.9 735 10/18/2019
2.0.8 809 10/18/2019
2.0.7 748 10/18/2019
2.0.6 742 10/18/2019
2.0.5 782 10/18/2019
2.0.4 742 10/17/2019
2.0.3 688 10/16/2019
2.0.2 702 10/15/2019
2.0.1 701 10/14/2019
2.0.0 638 10/13/2019
1.1.7 830 10/11/2019
1.1.6 811 10/11/2019