simpleapi.core 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package simpleapi.core --version 1.0.2                
NuGet\Install-Package simpleapi.core -Version 1.0.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.
<PackageReference Include="simpleapi.core" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add simpleapi.core --version 1.0.2                
#r "nuget: simpleapi.core, 1.0.2"                
#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 simpleapi.core as a Cake Addin
#addin nuget:?package=simpleapi.core&version=1.0.2

// Install simpleapi.core as a Cake Tool
#tool nuget:?package=simpleapi.core&version=1.0.2                

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 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.

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
1.0.4 240 11/24/2023
1.0.3 147 11/21/2023
1.0.2 119 11/21/2023
1.0.1 191 11/21/2023
1.0.0 208 11/21/2023

alpha