magic.library
17.3.9
dotnet add package magic.library --version 17.3.9
NuGet\Install-Package magic.library -Version 17.3.9
<PackageReference Include="magic.library" Version="17.3.9" />
paket add magic.library --version 17.3.9
#r "nuget: magic.library, 17.3.9"
// Install magic.library as a Cake Addin #addin nuget:?package=magic.library&version=17.3.9 // Install magic.library as a Cake Tool #tool nuget:?package=magic.library&version=17.3.9
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 8 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.
Magic's GitHub project page
Magic is 100% Open Source and you can find the primary project GitHub page here.
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.
Copyright and maintenance
The projects is copyright Thomas Hansen 2023 - 2024, and professionally maintained by AINIRO.IO.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- magic.endpoint (>= 17.2.0)
- magic.endpoint.services (>= 17.3.5)
- magic.lambda (>= 17.2.0)
- magic.lambda.auth (>= 17.2.0)
- magic.lambda.caching (>= 17.2.0)
- magic.lambda.config (>= 17.2.0)
- magic.lambda.crypto (>= 17.2.0)
- magic.lambda.csv (>= 17.2.0)
- magic.lambda.dates (>= 17.2.0)
- magic.lambda.guid (>= 17.2.0)
- magic.lambda.html (>= 17.3.9)
- magic.lambda.http (>= 17.2.0)
- magic.lambda.hyperlambda (>= 17.2.0)
- magic.lambda.image (>= 17.2.0)
- magic.lambda.io (>= 17.2.0)
- magic.lambda.json (>= 17.2.0)
- magic.lambda.logging (>= 17.2.0)
- magic.lambda.mail (>= 17.2.0)
- magic.lambda.math (>= 17.2.0)
- magic.lambda.mime (>= 17.2.0)
- magic.lambda.mssql (>= 17.2.0)
- magic.lambda.mysql (>= 17.2.0)
- magic.lambda.odbc (>= 17.2.0)
- magic.lambda.openai (>= 17.2.0)
- magic.lambda.pdf (>= 17.2.0)
- magic.lambda.pgsql (>= 17.2.0)
- magic.lambda.scheduler (>= 17.2.0)
- magic.lambda.slots (>= 17.2.1)
- magic.lambda.sockets (>= 17.2.0)
- magic.lambda.sqlite (>= 17.2.0)
- magic.lambda.strings (>= 17.3.3)
- magic.lambda.threading (>= 17.2.0)
- magic.lambda.validators (>= 17.2.0)
- magic.lambda.xml (>= 17.2.0)
- magic.signals (>= 17.2.0)
- Microsoft.AspNetCore.Diagnostics (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
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 | 259 | 2/17/2024 |
17.3.7 | 150 | 2/12/2024 |
17.3.6 | 120 | 2/12/2024 |
17.3.5 | 110 | 2/10/2024 |
17.3.4 | 108 | 2/9/2024 |
17.3.3 | 110 | 2/8/2024 |
17.3.2 | 122 | 2/2/2024 |
17.3.1 | 125 | 1/30/2024 |
17.2.2 | 97 | 1/30/2024 |
17.2.1 | 138 | 1/22/2024 |
17.2.0 | 114 | 1/22/2024 |
17.1.7 | 179 | 1/12/2024 |
17.1.6 | 147 | 1/11/2024 |
17.1.5 | 154 | 1/5/2024 |
17.0.1 | 211 | 1/1/2024 |
17.0.0 | 340 | 12/14/2023 |
16.11.6 | 241 | 11/14/2023 |
16.11.5 | 183 | 11/12/2023 |
16.9.0 | 303 | 10/9/2023 |
16.8.5 | 185 | 9/30/2023 |
16.8.4 | 178 | 9/25/2023 |
16.8.0 | 150 | 9/24/2023 |
16.7.51 | 144 | 9/24/2023 |
16.7.50 | 154 | 9/23/2023 |
16.7.1 | 200 | 9/4/2023 |
16.7.0 | 309 | 7/11/2023 |
16.6.13 | 199 | 7/6/2023 |
16.6.12 | 196 | 7/5/2023 |
16.6.11 | 184 | 7/5/2023 |
16.6.5 | 222 | 7/3/2023 |
16.4.4 | 222 | 7/2/2023 |
16.4.3 | 231 | 6/27/2023 |
16.4.2 | 223 | 6/25/2023 |
16.4.1 | 223 | 6/25/2023 |
16.4.0 | 209 | 6/22/2023 |
16.3.2 | 300 | 6/7/2023 |
16.3.0 | 308 | 5/28/2023 |
16.2.0 | 388 | 5/13/2023 |
16.1.10 | 368 | 5/1/2023 |
16.1.9 | 287 | 4/30/2023 |
16.1.1 | 308 | 4/20/2023 |
15.10.11 | 330 | 4/16/2023 |
15.9.40 | 363 | 4/3/2023 |
15.9.1 | 419 | 3/27/2023 |
15.9.0 | 424 | 3/24/2023 |
15.8.2 | 464 | 3/20/2023 |
15.7.0 | 346 | 3/6/2023 |
15.5.20 | 714 | 2/23/2023 |
15.5.13 | 515 | 2/13/2023 |
15.5.9 | 408 | 2/11/2023 |
15.5.2 | 489 | 2/5/2023 |
15.5.1 | 403 | 2/3/2023 |
15.5.0 | 478 | 1/28/2023 |
15.2.0 | 622 | 1/18/2023 |
15.1.0 | 1,090 | 12/28/2022 |
14.5.7 | 630 | 12/13/2022 |
14.5.5 | 731 | 12/6/2022 |
14.5.1 | 565 | 11/23/2022 |
14.5.0 | 511 | 11/18/2022 |
14.4.5 | 587 | 10/22/2022 |
14.4.2 | 515 | 10/22/2022 |
14.4.1 | 520 | 10/22/2022 |
14.4.0 | 553 | 10/17/2022 |
14.3.9 | 573 | 10/13/2022 |
14.3.6 | 576 | 10/7/2022 |
14.3.2 | 585 | 9/18/2022 |
14.3.1 | 665 | 9/12/2022 |
14.3.0 | 558 | 9/10/2022 |
14.1.3 | 820 | 8/7/2022 |
14.1.2 | 570 | 8/7/2022 |
14.1.1 | 578 | 8/7/2022 |
14.0.14 | 570 | 7/26/2022 |
14.0.12 | 560 | 7/24/2022 |
14.0.11 | 536 | 7/23/2022 |
14.0.10 | 555 | 7/23/2022 |
14.0.9 | 538 | 7/23/2022 |
14.0.8 | 626 | 7/17/2022 |
14.0.5 | 694 | 7/11/2022 |
14.0.4 | 628 | 7/7/2022 |
14.0.3 | 620 | 7/2/2022 |
14.0.2 | 565 | 7/2/2022 |
14.0.1 | 610 | 7/2/2022 |
14.0.0 | 590 | 6/25/2022 |
13.4.28 | 582 | 6/11/2022 |
13.4.25 | 694 | 6/9/2022 |
13.4.24 | 584 | 6/9/2022 |
13.4.19 | 636 | 6/8/2022 |
13.4.3 | 612 | 6/6/2022 |
13.4.2 | 649 | 6/4/2022 |
13.4.0 | 669 | 5/31/2022 |
13.3.8 | 643 | 5/19/2022 |
13.3.7 | 602 | 5/18/2022 |
13.3.6 | 645 | 5/14/2022 |
13.3.4 | 719 | 5/9/2022 |
13.3.1 | 654 | 5/1/2022 |
13.3.0 | 614 | 5/1/2022 |
13.2.2 | 670 | 4/25/2022 |
13.2.1 | 627 | 4/25/2022 |
13.2.0 | 656 | 4/21/2022 |
13.1.1 | 675 | 4/20/2022 |
13.1.0 | 750 | 4/7/2022 |
13.0.0 | 686 | 4/5/2022 |
12.0.3 | 849 | 3/14/2022 |
11.0.7 | 726 | 3/11/2022 |
11.0.5 | 780 | 3/2/2022 |
11.0.4 | 701 | 2/22/2022 |
11.0.3 | 702 | 2/9/2022 |
11.0.2 | 757 | 2/6/2022 |
11.0.1 | 749 | 2/5/2022 |
10.0.21 | 715 | 1/28/2022 |
10.0.20 | 733 | 1/27/2022 |
10.0.19 | 715 | 1/23/2022 |
10.0.18 | 684 | 1/17/2022 |
10.0.17 | 697 | 1/14/2022 |
10.0.16 | 549 | 1/2/2022 |
10.0.15 | 606 | 12/31/2021 |
10.0.14 | 618 | 12/28/2021 |
10.0.13 | 688 | 12/23/2021 |
10.0.11 | 479 | 12/23/2021 |
10.0.10 | 498 | 12/22/2021 |
10.0.9 | 656 | 12/22/2021 |
10.0.8 | 543 | 12/22/2021 |
10.0.7 | 699 | 12/22/2021 |
10.0.6 | 582 | 12/19/2021 |
10.0.5 | 677 | 12/18/2021 |
10.0.3 | 461 | 12/16/2021 |
10.0.2 | 540 | 12/14/2021 |
10.0.1 | 432 | 12/13/2021 |
10.0.0 | 477 | 12/6/2021 |
9.9.9 | 1,263 | 11/29/2021 |
9.9.6 | 4,732 | 11/24/2021 |
9.9.5 | 481 | 11/23/2021 |
9.9.4 | 779 | 11/21/2021 |
9.9.3 | 550 | 11/9/2021 |
9.9.2 | 568 | 11/4/2021 |
9.9.0 | 668 | 10/30/2021 |
9.8.9 | 689 | 10/29/2021 |
9.8.7 | 577 | 10/27/2021 |
9.8.6 | 585 | 10/27/2021 |
9.8.5 | 677 | 10/26/2021 |
9.8.4 | 650 | 10/25/2021 |
9.8.3 | 703 | 10/24/2021 |
9.8.1 | 574 | 10/21/2021 |
9.8.0 | 649 | 10/20/2021 |
9.7.9 | 563 | 10/20/2021 |
9.7.8 | 596 | 10/19/2021 |
9.7.7 | 830 | 10/17/2021 |
9.7.6 | 726 | 10/17/2021 |
9.7.5 | 601 | 10/14/2021 |
9.7.1 | 539 | 10/14/2021 |
9.7.0 | 615 | 10/9/2021 |
9.6.8 | 625 | 8/30/2021 |
9.6.7 | 602 | 8/26/2021 |
9.6.6 | 714 | 8/14/2021 |
9.6.5 | 818 | 8/11/2021 |
9.6.4 | 613 | 8/10/2021 |
9.6.3 | 603 | 8/9/2021 |
9.6.2 | 602 | 8/8/2021 |
9.6.1 | 560 | 8/8/2021 |
9.5.9 | 757 | 8/5/2021 |
9.5.8 | 753 | 8/4/2021 |
9.5.3 | 638 | 7/20/2021 |
9.5.0 | 1,004 | 7/9/2021 |
9.4.5 | 613 | 6/29/2021 |
9.4.4 | 761 | 6/29/2021 |
9.4.0 | 604 | 6/24/2021 |
9.3.7 | 612 | 6/21/2021 |
9.3.6 | 664 | 6/21/2021 |
9.3.5 | 792 | 6/18/2021 |
9.3.4 | 722 | 6/18/2021 |
9.2.5 | 771 | 6/7/2021 |
9.2.4 | 709 | 6/6/2021 |
9.2.3 | 645 | 6/6/2021 |
9.2.2 | 554 | 6/4/2021 |
9.2.1 | 789 | 6/1/2021 |
9.2.0 | 747 | 5/26/2021 |
9.1.9 | 562 | 5/5/2021 |
9.1.8 | 715 | 5/5/2021 |
9.1.7 | 572 | 5/3/2021 |
9.1.4 | 581 | 4/21/2021 |
9.1.2 | 567 | 4/18/2021 |
9.1.1 | 552 | 4/15/2021 |
9.1.0 | 606 | 4/14/2021 |
9.0.1 | 672 | 4/12/2021 |
9.0.0 | 569 | 4/5/2021 |
8.9.92 | 1,142 | 3/30/2021 |
8.9.4 | 1,154 | 3/26/2021 |
8.9.3 | 1,196 | 3/19/2021 |
8.9.2 | 1,177 | 1/29/2021 |
8.9.1 | 1,242 | 1/24/2021 |
8.9.0 | 1,308 | 1/22/2021 |
8.7.1 | 1,611 | 11/15/2020 |
8.7.0 | 1,314 | 11/15/2020 |
8.6.9 | 1,251 | 11/8/2020 |
8.6.7 | 1,223 | 11/4/2020 |
8.6.6 | 1,308 | 11/2/2020 |
8.6.5 | 1,288 | 11/1/2020 |
8.6.3 | 1,309 | 10/30/2020 |
8.6.2 | 1,213 | 10/30/2020 |
8.6.1 | 1,304 | 10/29/2020 |
8.6.0 | 1,263 | 10/28/2020 |
8.5.1 | 1,253 | 10/26/2020 |
8.5.0 | 1,202 | 10/23/2020 |
8.4.6 | 1,421 | 10/20/2020 |
8.4.5 | 1,304 | 10/18/2020 |
8.4.4 | 1,325 | 10/17/2020 |
8.4.3 | 1,292 | 10/16/2020 |
8.4.2 | 1,241 | 10/16/2020 |
8.4.1 | 1,239 | 10/15/2020 |
8.4.0 | 1,316 | 10/13/2020 |
8.3.3 | 1,240 | 10/11/2020 |
8.3.2 | 1,283 | 10/8/2020 |
8.3.1 | 1,300 | 10/5/2020 |
8.3.0 | 1,252 | 10/3/2020 |
8.2.3 | 1,209 | 10/1/2020 |
8.2.2 | 1,489 | 9/26/2020 |
8.2.1 | 1,349 | 9/25/2020 |
8.2.0 | 1,383 | 9/25/2020 |
8.1.25 | 1,279 | 9/24/2020 |
8.1.24 | 1,272 | 9/23/2020 |
8.1.23 | 1,200 | 9/23/2020 |
8.1.22 | 1,271 | 9/21/2020 |
8.1.21 | 1,324 | 9/15/2020 |
8.1.20 | 1,333 | 9/14/2020 |
8.1.19 | 1,310 | 9/13/2020 |
8.1.18 | 1,278 | 9/13/2020 |
8.1.17 | 1,328 | 9/13/2020 |
8.1.16 | 1,327 | 9/13/2020 |
8.1.15 | 1,252 | 9/12/2020 |
8.1.13 | 1,147 | 9/11/2020 |
8.1.12 | 1,271 | 9/11/2020 |
8.1.11 | 1,274 | 9/11/2020 |
8.1.10 | 1,319 | 9/6/2020 |
8.1.9 | 1,317 | 9/3/2020 |
8.1.8 | 1,341 | 9/2/2020 |
8.1.7 | 1,209 | 8/28/2020 |
8.1.4 | 1,210 | 8/25/2020 |
8.1.3 | 1,383 | 8/18/2020 |
8.1.2 | 1,200 | 8/16/2020 |
8.1.1 | 1,262 | 8/15/2020 |
8.0.3 | 1,276 | 8/11/2020 |
8.0.2 | 1,298 | 8/7/2020 |
8.0.1 | 1,301 | 8/7/2020 |
8.0.0 | 1,246 | 8/7/2020 |
7.0.1 | 1,357 | 6/28/2020 |
7.0.0 | 1,349 | 6/28/2020 |
5.0.10 | 1,318 | 5/31/2020 |
5.0.9 | 1,417 | 5/30/2020 |
5.0.8 | 1,295 | 5/29/2020 |
5.0.7 | 1,262 | 5/29/2020 |
5.0.5 | 1,353 | 2/27/2020 |
5.0.4 | 1,322 | 2/26/2020 |
5.0.3 | 1,313 | 2/26/2020 |
5.0.2 | 1,319 | 2/25/2020 |
5.0.1 | 1,222 | 2/25/2020 |
5.0.0 | 1,340 | 2/25/2020 |
4.1.5 | 1,281 | 2/23/2020 |
4.1.4 | 1,364 | 2/23/2020 |
4.1.3 | 1,299 | 2/22/2020 |
4.1.2 | 1,292 | 2/22/2020 |
4.1.1 | 1,284 | 2/21/2020 |
4.1.0 | 1,315 | 2/21/2020 |
4.0.9 | 1,405 | 2/7/2020 |
4.0.8 | 1,239 | 2/7/2020 |
4.0.7 | 1,262 | 2/7/2020 |
4.0.5 | 1,275 | 1/28/2020 |
4.0.4 | 1,407 | 1/27/2020 |
4.0.3 | 1,259 | 1/27/2020 |
4.0.2 | 1,402 | 1/16/2020 |
4.0.1 | 1,424 | 1/11/2020 |
4.0.0 | 1,373 | 1/5/2020 |
3.1.7 | 1,423 | 12/17/2019 |
3.1.6 | 1,312 | 12/12/2019 |
3.1.5 | 1,308 | 12/12/2019 |
3.1.4 | 1,322 | 12/5/2019 |
3.1.3 | 1,357 | 12/4/2019 |
3.1.2 | 1,380 | 11/30/2019 |
3.1.1 | 1,541 | 11/26/2019 |
3.1.0 | 1,341 | 11/10/2019 |
3.0.4 | 1,182 | 11/1/2019 |
3.0.3 | 1,348 | 10/28/2019 |
3.0.2 | 1,362 | 10/28/2019 |
3.0.1 | 1,353 | 10/26/2019 |
3.0.0 | 1,181 | 10/23/2019 |
2.1.4 | 978 | 10/21/2019 |
2.1.3 | 1,314 | 10/21/2019 |
2.1.2 | 1,445 | 10/21/2019 |
2.1.1 | 1,320 | 10/19/2019 |
2.1.0 | 1,370 | 10/19/2019 |
2.0.9 | 1,067 | 10/18/2019 |
2.0.8 | 1,338 | 10/18/2019 |
2.0.7 | 1,075 | 10/18/2019 |
2.0.6 | 1,064 | 10/18/2019 |
2.0.5 | 1,119 | 10/18/2019 |
2.0.4 | 1,078 | 10/17/2019 |
2.0.3 | 1,211 | 10/16/2019 |
2.0.2 | 1,195 | 10/15/2019 |
2.0.1 | 1,238 | 10/14/2019 |
2.0.0 | 1,074 | 10/13/2019 |
1.1.7 | 1,406 | 10/11/2019 |
1.1.6 | 1,354 | 10/11/2019 |