simpleapi.core
1.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global simpleapi.core --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local simpleapi.core --version 1.0.1
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=simpleapi.core&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package simpleapi.core --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
simple-api project
simple-api project is an attempt to create a framework for creating very transparent in terms of code and efficient API-type applications. In accordance with the principle of Domain Driven Design, each endpoint is a separate class, which allows for very simple work on the entire project.
The framework allows you to
- Creating API interface (http/https)
- Middlewares implementations
- Dependency injection *
- Simple UI for testing and creating documentation *.
- Web page construction *
implementation
Construction of the API interface
If you want to start a server
IApp app = App.Init<Program>(5050)
app.Run();
Construction of Endpoints
[Api("/example", Method.GET)]
public static class ExampleEndpoint
{
public class Command
{
public int A { get; set; }
public int B { get; set; }
public int C { get; set; }
}
public class Handler : IEndpoint<Command, int>
{
public async Task<int> Handle(Command command)
{
//TODO all features
return command.A + command.B + command.C;
}
}
}
Command is a class that has a request body in it if it is a GET it will be taken from the parameters in the URL, if it is a method that has a body it will be built from JSON
Construction of Middleware
if you want to create middleware you must instantiate the class
public class ExampleMiddleware : IMiddleware
{
public async Task<HttpListenerContext> Invoke(HttpListenerContext ctx)
{
Console.WriteLine("TODO somethink cool");
return ctx;
}
}
And then register it on the App object
IApp app = App.Init<Program>(5050)
.AddMiddleware<ExampleMiddleware>();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. net8.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
alpha