GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - PasoUnleashed/FastAPI.Net: FastAPI.Net is a standalone API library that allows developers to create standalone api servers with ease.

BranchesTags
Open more actions menu

Latest commit

 

History

36 Commits
36 Commits

Folders and files

NameName
Last commit message
Last commit date
FastAPI.Net
FastAPI.Net
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

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;
    }
}

About

FastAPI.Net is a standalone API library that allows developers to create standalone api servers with ease.

www.nuget.org/packages/FastAPI.Net/

Resources

Readme
MIT license
Activity

Stars

3 stars

Watchers

1 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.