SAPI is a library for creating APIs with C#. It's simple by design and allows for a lot of flexibility.
Add as dependency in NuGet
Install-Package SAPI -ProjectName <project>
By downloading and referencing the DLL (and its dependencies) in your project.
For detailed explanation You can also see docs
// Program.cs
using SAPI;
using SAPI.Endpoints;
using Project.Endpoints;
public static void Main(string[] args)
{
// Init SAPI
Server sapi = new();
sapi.Start();
}
// Endpoints/Ping.cs
using System.Net;
using SAPI;
namespace Project.Endpoints
{
public class Ping : Endpoint
{
public override string url { get; } = "ping";
private override void Get(ref Packet packet)
{
Console.WriteLine("Ping!");
Error.Page(HttpStatus.EnhanceYourCalm, ref packet);
}
}
}