FastAPI.Net 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FastAPI.Net --version 1.2.0
                    
NuGet\Install-Package FastAPI.Net -Version 1.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="FastAPI.Net" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FastAPI.Net" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="FastAPI.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FastAPI.Net --version 1.2.0
                    
#r "nuget: FastAPI.Net, 1.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.
#:package FastAPI.Net@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FastAPI.Net&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=FastAPI.Net&version=1.2.0
                    
Install as a Cake Tool

FastAPI.Net

FastAPI is a standalone API server library. Has a very simmilliar structure to asp.net mvc api webapp. With very little third party library dependencies.

Install

Nuget

Todo

  • Minimal Access Check
  • Edge cases for parameters
  • ResponseObject with status code/message
  • Debugging and Logging
  • Accounting

Example

class Program
{
    static void Main(string[] args)
    {
        // Create configuration
        var config = new ServerConfig().UseHttps(false).VerboseExceptions(true);             
        // Create server
        var api = new Server(config, "localhost", 8080);
        // Start the server
        api.Start();
        // Rest of the appliaction.
        while (true) ;
    }
}
[Route("/api")] //http://localhost:8080/api
public class Controller1:Controller
{

    void AuthCheck()
    {
        if (this.Identity != null)
        {
            Console.WriteLine("Found Identity");
        }
        else
        {
            Console.WriteLine("No Identity");
        }
    }
    [HttpPut] //http://localhost:8080/api/AddPerson/1
    [Route("./AddPerson/")]
    public void AddPerson(Person p)
    {
        Console.WriteLine($"Adding person with id {p.ID}");
    }
    [Route("./{id}")] //http://localhost:8080/api/4120
    public Person GetPerson(int id)
    {
        Console.WriteLine($"Returning person with id {id}");
        return new Person(id, "somePerson", DateTime.Now);
    }
    static Random r = new Random();
    [HttpGet]
    [Route("./response")]
    public HttpResponse Random()
    {
        var rg = r.NextDouble();
        if (rg> 0.666)
        {
            throw new Exception("unhandled error");
        }else if (rg > 0.333)
        {
            return HttpResponse.CreateError(500, new Exception("internal error"));
        }
        else
        {
            return HttpResponse.CreateSuccess("Success");
        }
        
    }
}
/// <summary>
/// Our authentication class
/// </summary>
public class Auth : FastAPI.Net.Authentication.AuthenticationIdentity
{
    // The identity will be created if the request header contains the constructor's parameters.
    public Auth(string username)
    {
        Console.WriteLine($"username:{username}");
    }
    // Everyone get's basic access in this implementation
    public override bool HasMinimalAccess()
    {
        return true;
    }
}

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.3.0 805 10/17/2021
1.2.0 536 10/11/2021
1.1.1 460 10/10/2021
1.1.0 465 10/10/2021
1.0.5 649 10/9/2021
1.0.4 667 10/9/2021
1.0.3 462 10/9/2021
1.0.2 482 10/9/2021
1.0.1 482 10/9/2021
1.0.0 475 10/9/2021