Welcome to MinimalApiMapper! This project enables a structured approach to organizing ASP.NET Core Minimal APIs, similar to the MVC framework. It offers full Native AOT support through efficient source generation.
- MVC-like Organization: Structure your Minimal APIs like traditional MVC applications.
- Native AOT Support: Enjoy the benefits of Ahead-of-Time compilation for better performance.
- Source Generation: Automatically generate code to reduce boilerplate and improve productivity.
- Dependency Injection: Seamlessly integrate with ASP.NET Core's built-in dependency injection.
- Performance Optimizations: Enhance your APIs with native performance improvements.
To start using MinimalApiMapper, you can download the latest release from here. After downloading, execute the necessary files to set up your environment.
Before you begin, ensure you have the following installed:
- .NET SDK (version 6.0 or higher)
- An IDE or text editor of your choice (e.g., Visual Studio, Visual Studio Code)
You can install MinimalApiMapper via NuGet. Run the following command in your terminal:
dotnet add package MinimalApiMapper
Alternatively, you can download the package directly from the Releases section.
Here’s a simple example to help you get started:
-
Create a new ASP.NET Core project:
dotnet new web -n MyMinimalApi cd MyMinimalApi
-
Add MinimalApiMapper:
dotnet add package MinimalApiMapper
-
Configure your API:
Open
Program.cs
and set up your Minimal APIs using the mapper.using MinimalApiMapper; var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("/api/hello", () => "Hello, World!"); app.Run();
-
Run your application:
dotnet run
-
Access your API:
Open your browser and navigate to
http://localhost:5000/api/hello
. You should see "Hello, World!" displayed.
MinimalApiMapper allows for more advanced configurations. You can customize your routing, middleware, and dependency injection setup.
To create custom routes, simply define them in your Program.cs
:
app.MapGet("/api/greet/{name}", (string name) => $"Hello, {name}!");
You can add middleware to your application as follows:
app.Use(async (context, next) =>
{
// Do something before the next middleware
await next.Invoke();
// Do something after the next middleware
});
We welcome contributions! To contribute to MinimalApiMapper, follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-YourFeature
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-YourFeature
). - Open a pull request.
Please ensure your code adheres to the existing style and includes tests where applicable.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or issues, feel free to reach out:
- GitHub: laura5v
- Email: laura@example.com
Thank you for checking out MinimalApiMapper! We hope it helps you streamline your ASP.NET Core Minimal API development. For more updates and releases, visit our Releases section.
Topics: aot, api, asp-net-core, code-generation, csharp, dependency-injection, dotnet, minimal-apis, native-aot, performance, roslyn, source-generator, webapi.
Happy coding!