Skip to content

Code generated Web API framework for .NET Core

Notifications You must be signed in to change notification settings

nikolaidk/uController

 
 

Repository files navigation

uController (pronounced micro (μ) controller)

feedz.io

A declarative micro-framework inspired by ASP.NET Core MVC but using C# source generators.

  • Built on top of ASP.NET Core
  • AOT friendly (using source generators)

Differences from MVC

  • No discovery of "controllers"
  • No base class required
  • Support for basic and very efficient model binding (FromQuery, FromHeader, FromForm, FromBody)
  • No validation or any extensiblity besides IResult
  • One type of filter (not wired up yet)

There are 2 packages:

  • uController - The main package that contains the framework primitives and runtime code generation logic.
  • uController.SourceGenerator - The source generator that overrides the runtime code generation with compile time logic.

Hello World

using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;

public class Startup
{
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHttpHandler<HelloHandler>();
        });
    }
}

public class HelloHandler
{
    [HttpGet("/")]
    public string Hello() => "Hello uController";
}

The source generator will build extremely efficient code (what you would have hand written yourself) for invoking your handler methods!

Using CI Builds

To use CI builds add the following nuget feed:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <clear />
        <add key="ucontroller" value="https://f.feedz.io/davidfowl/ucontroller/nuget/index.json" />
        <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
</configuration>

See the list of versions

About

Code generated Web API framework for .NET Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%