SAPI 2.2.0

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

// Install SAPI as a Cake Tool
#tool nuget:?package=SAPI&version=2.2.0

SAPI - Simple API

SAPI is a library for creating APIs with C#. It's simple by design and allows for a lot of flexibility.

Installation

Add as dependency in NuGet

Install-Package SAPI -ProjectName <project>

or in your preferred IDE: SAPI in rider's NuGet PM

you can also use SAPI by downloading and referencing the DLL in your project.

Usage

For detailed explanation You can also see wiki wiki

// Program.cs
using SAPI;
using SAPI.Endpoints;
using Project.Endpoints;

public static void Main(string[] args)
{
    // Init SAPI
    Server sapi = new();
    
    // Mount endpoints(routes)
    // sapi.MountEndpoint(new Ping("ping", Method.GET)) - this is an old method - now deprecated, use this:
    sapi.MountIEndpoint(new Ping());
    
    
    // Finally start SAPI
    sapi.Start();
}
// Endpoints/Ping.cs
using System.Net;
using SAPI.Endpoints;
using SAPI.Utilities;

namespace Project.Endpoints
{
    // public class Ping : Endpoint - this is an old method - now deprecated, use this:
    public class Ping : IEndpoint
    {
        // New things: these are the parameters for the endpoint, that were present in constructor - now they are here
        public string url { get; } = "ping";
        public Method method { get; } = Method.GET;

        public override void Task(ref HttpListenerRequest request, ref HttpListenerResponse response)
        {
            Console.WriteLine("Ping!");
            
            Utilities.HtmlResponse("Pong!", ref response);
        }
    }
}
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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SAPI:

Package Downloads
SharpSSR

SharpSSR is a web framework for building Server Side Rendered apps.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
10.0.0 376 7/26/2023
9.1.0 199 5/15/2023
9.0.0 173 5/4/2023
8.0.0 155 5/1/2023
7.0.0 178 4/25/2023
6.0.0 205 3/11/2023
6.0.0-experimental 137 2/8/2023
5.0.1 207 12/24/2022
5.0.0 198 12/6/2022
4.0.0 200 11/9/2022
3.0.0 205 11/6/2022
2.2.0 195 10/31/2022
2.1.0 227 10/5/2022
2.0.0 218 9/28/2022
1.2.0 249 9/15/2022
1.1.0 264 9/14/2022
1.0.0 282 9/14/2022