magic.library 16.8.5

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

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

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 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 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 of Aista, Ltd 2021 - 2023, and professionally maintained by AINIRO your friendly ChatGPT website chatbot vendor.

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. 
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
16.8.5 79 9/30/2023
16.8.4 96 9/25/2023
16.8.0 74 9/24/2023
16.7.51 67 9/24/2023
16.7.50 76 9/23/2023
16.7.1 125 9/4/2023
16.7.0 225 7/11/2023
16.6.13 131 7/6/2023
16.6.12 126 7/5/2023
16.6.11 107 7/5/2023
16.6.5 153 7/3/2023
16.4.4 153 7/2/2023
16.4.3 172 6/27/2023
16.4.2 156 6/25/2023
16.4.1 147 6/25/2023
16.4.0 139 6/22/2023
16.3.2 230 6/7/2023
16.3.0 245 5/28/2023
16.2.0 318 5/13/2023
16.1.10 299 5/1/2023
16.1.9 227 4/30/2023
16.1.1 244 4/20/2023
15.10.11 264 4/16/2023
15.9.40 293 4/3/2023
15.9.1 346 3/27/2023
15.9.0 363 3/24/2023
15.8.2 399 3/20/2023
15.7.0 281 3/6/2023
15.5.20 631 2/23/2023
15.5.13 432 2/13/2023
15.5.9 329 2/11/2023
15.5.2 389 2/5/2023
15.5.1 328 2/3/2023
15.5.0 404 1/28/2023
15.2.0 539 1/18/2023
15.1.0 1,010 12/28/2022
14.5.7 551 12/13/2022
14.5.5 667 12/6/2022
14.5.1 503 11/23/2022
14.5.0 447 11/18/2022
14.4.5 520 10/22/2022
14.4.2 451 10/22/2022
14.4.1 447 10/22/2022
14.4.0 472 10/17/2022
14.3.9 490 10/13/2022
14.3.6 508 10/7/2022
14.3.2 506 9/18/2022
14.3.1 617 9/12/2022
14.3.0 498 9/10/2022
14.1.3 762 8/7/2022
14.1.2 517 8/7/2022
14.1.1 516 8/7/2022
14.0.14 516 7/26/2022
14.0.12 506 7/24/2022
14.0.11 487 7/23/2022
14.0.10 496 7/23/2022
14.0.9 488 7/23/2022
14.0.8 575 7/17/2022
14.0.5 643 7/11/2022
14.0.4 593 7/7/2022
14.0.3 567 7/2/2022
14.0.2 515 7/2/2022
14.0.1 553 7/2/2022
14.0.0 537 6/25/2022
13.4.28 516 6/11/2022
13.4.25 634 6/9/2022
13.4.24 533 6/9/2022
13.4.19 577 6/8/2022
13.4.3 553 6/6/2022
13.4.2 590 6/4/2022
13.4.0 611 5/31/2022
13.3.8 585 5/19/2022
13.3.7 551 5/18/2022
13.3.6 590 5/14/2022
13.3.4 661 5/9/2022
13.3.1 605 5/1/2022
13.3.0 564 5/1/2022
13.2.2 620 4/25/2022
13.2.1 572 4/25/2022
13.2.0 603 4/21/2022
13.1.1 624 4/20/2022
13.1.0 676 4/7/2022
13.0.0 629 4/5/2022
12.0.3 770 3/14/2022
11.0.7 654 3/11/2022
11.0.5 706 3/2/2022
11.0.4 635 2/22/2022
11.0.3 646 2/9/2022
11.0.2 701 2/6/2022
11.0.1 695 2/5/2022
10.0.21 650 1/28/2022
10.0.20 672 1/27/2022
10.0.19 659 1/23/2022
10.0.18 630 1/17/2022
10.0.17 642 1/14/2022
10.0.16 494 1/2/2022
10.0.15 549 12/31/2021
10.0.14 565 12/28/2021
10.0.13 637 12/23/2021
10.0.11 427 12/23/2021
10.0.10 448 12/22/2021
10.0.9 607 12/22/2021
10.0.8 486 12/22/2021
10.0.7 647 12/22/2021
10.0.6 522 12/19/2021
10.0.5 622 12/18/2021
10.0.3 405 12/16/2021
10.0.2 490 12/14/2021
10.0.1 376 12/13/2021
10.0.0 425 12/6/2021
9.9.9 1,193 11/29/2021
9.9.6 4,669 11/24/2021
9.9.5 426 11/23/2021
9.9.4 723 11/21/2021
9.9.3 489 11/9/2021
9.9.2 512 11/4/2021
9.9.0 612 10/30/2021
9.8.9 632 10/29/2021
9.8.7 523 10/27/2021
9.8.6 521 10/27/2021
9.8.5 637 10/26/2021
9.8.4 594 10/25/2021
9.8.3 651 10/24/2021
9.8.1 524 10/21/2021
9.8.0 595 10/20/2021
9.7.9 523 10/20/2021
9.7.8 547 10/19/2021
9.7.7 778 10/17/2021
9.7.6 667 10/17/2021
9.7.5 548 10/14/2021
9.7.1 485 10/14/2021
9.7.0 559 10/9/2021
9.6.8 580 8/30/2021
9.6.7 546 8/26/2021
9.6.6 655 8/14/2021
9.6.5 758 8/11/2021
9.6.4 553 8/10/2021
9.6.3 561 8/9/2021
9.6.2 538 8/8/2021
9.6.1 500 8/8/2021
9.5.9 697 8/5/2021
9.5.8 696 8/4/2021
9.5.3 579 7/20/2021
9.5.0 947 7/9/2021
9.4.5 561 6/29/2021
9.4.4 707 6/29/2021
9.4.0 539 6/24/2021
9.3.7 560 6/21/2021
9.3.6 613 6/21/2021
9.3.5 743 6/18/2021
9.3.4 671 6/18/2021
9.2.5 719 6/7/2021
9.2.4 650 6/6/2021
9.2.3 595 6/6/2021
9.2.2 505 6/4/2021
9.2.1 731 6/1/2021
9.2.0 698 5/26/2021
9.1.9 507 5/5/2021
9.1.8 660 5/5/2021
9.1.7 522 5/3/2021
9.1.4 530 4/21/2021
9.1.2 512 4/18/2021
9.1.1 499 4/15/2021
9.1.0 550 4/14/2021
9.0.1 616 4/12/2021
9.0.0 519 4/5/2021
8.9.92 1,080 3/30/2021
8.9.4 1,104 3/26/2021
8.9.3 1,127 3/19/2021
8.9.2 1,122 1/29/2021
8.9.1 1,189 1/24/2021
8.9.0 1,255 1/22/2021
8.7.1 1,549 11/15/2020
8.7.0 1,255 11/15/2020
8.6.9 1,193 11/8/2020
8.6.7 1,173 11/4/2020
8.6.6 1,266 11/2/2020
8.6.5 1,234 11/1/2020
8.6.3 1,254 10/30/2020
8.6.2 1,164 10/30/2020
8.6.1 1,251 10/29/2020
8.6.0 1,199 10/28/2020
8.5.1 1,196 10/26/2020
8.5.0 1,162 10/23/2020
8.4.6 1,360 10/20/2020
8.4.5 1,235 10/18/2020
8.4.4 1,268 10/17/2020
8.4.3 1,245 10/16/2020
8.4.2 1,188 10/16/2020
8.4.1 1,184 10/15/2020
8.4.0 1,268 10/13/2020
8.3.3 1,186 10/11/2020
8.3.2 1,232 10/8/2020
8.3.1 1,243 10/5/2020
8.3.0 1,194 10/3/2020
8.2.3 1,143 10/1/2020
8.2.2 1,433 9/26/2020
8.2.1 1,298 9/25/2020
8.2.0 1,314 9/25/2020
8.1.25 1,227 9/24/2020
8.1.24 1,226 9/23/2020
8.1.23 1,161 9/23/2020
8.1.22 1,218 9/21/2020
8.1.21 1,273 9/15/2020
8.1.20 1,283 9/14/2020
8.1.19 1,268 9/13/2020
8.1.18 1,217 9/13/2020
8.1.17 1,278 9/13/2020
8.1.16 1,267 9/13/2020
8.1.15 1,189 9/12/2020
8.1.13 1,094 9/11/2020
8.1.12 1,220 9/11/2020
8.1.11 1,214 9/11/2020
8.1.10 1,258 9/6/2020
8.1.9 1,257 9/3/2020
8.1.8 1,292 9/2/2020
8.1.7 1,151 8/28/2020
8.1.4 1,153 8/25/2020
8.1.3 1,330 8/18/2020
8.1.2 1,154 8/16/2020
8.1.1 1,213 8/15/2020
8.0.3 1,221 8/11/2020
8.0.2 1,241 8/7/2020
8.0.1 1,240 8/7/2020
8.0.0 1,195 8/7/2020
7.0.1 1,295 6/28/2020
7.0.0 1,290 6/28/2020
5.0.10 1,245 5/31/2020
5.0.9 1,342 5/30/2020
5.0.8 1,241 5/29/2020
5.0.7 1,202 5/29/2020
5.0.5 1,310 2/27/2020
5.0.4 1,259 2/26/2020
5.0.3 1,269 2/26/2020
5.0.2 1,278 2/25/2020
5.0.1 1,161 2/25/2020
5.0.0 1,289 2/25/2020
4.1.5 1,216 2/23/2020
4.1.4 1,307 2/23/2020
4.1.3 1,245 2/22/2020
4.1.2 1,240 2/22/2020
4.1.1 1,224 2/21/2020
4.1.0 1,264 2/21/2020
4.0.9 1,354 2/7/2020
4.0.8 1,184 2/7/2020
4.0.7 1,206 2/7/2020
4.0.5 1,230 1/28/2020
4.0.4 1,352 1/27/2020
4.0.3 1,210 1/27/2020
4.0.2 1,347 1/16/2020
4.0.1 1,353 1/11/2020
4.0.0 1,314 1/5/2020
3.1.7 1,344 12/17/2019
3.1.6 1,268 12/12/2019
3.1.5 1,257 12/12/2019
3.1.4 1,276 12/5/2019
3.1.3 1,306 12/4/2019
3.1.2 1,322 11/30/2019
3.1.1 1,473 11/26/2019
3.1.0 1,279 11/10/2019
3.0.4 1,122 11/1/2019
3.0.3 1,291 10/28/2019
3.0.2 1,305 10/28/2019
3.0.1 1,313 10/26/2019
3.0.0 1,116 10/23/2019
2.1.4 907 10/21/2019
2.1.3 1,270 10/21/2019
2.1.2 1,382 10/21/2019
2.1.1 1,262 10/19/2019
2.1.0 1,309 10/19/2019
2.0.9 1,008 10/18/2019
2.0.8 1,283 10/18/2019
2.0.7 1,006 10/18/2019
2.0.6 1,012 10/18/2019
2.0.5 1,054 10/18/2019
2.0.4 1,013 10/17/2019
2.0.3 1,147 10/16/2019
2.0.2 1,138 10/15/2019
2.0.1 1,181 10/14/2019
2.0.0 888 10/13/2019
1.1.7 1,316 10/11/2019
1.1.6 1,294 10/11/2019