Skip to content

Maciejowski2006/SAPI

Repository files navigation

SAPI - Simple API

Nuget NuGet GitHub

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>

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

By downloading and referencing the DLL (and its dependencies) in your project.

Usage

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);
        }
    }
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy