StatsHelix.Charizard 0.10.3

A lean, performant C#-Webserver, mainly for SPAs.

Install-Package StatsHelix.Charizard -Version 0.10.3
dotnet add package StatsHelix.Charizard --version 0.10.3
<PackageReference Include="StatsHelix.Charizard" Version="0.10.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StatsHelix.Charizard --version 0.10.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

StatsHelix.Charizard

The StatsHelix Charizard web framework.

Example

using System;
using System.Net;
using System.Threading.Tasks;

using StatsHelix.Charizard;
using static StatsHelix.Charizard.HttpResponse;

namespace TestApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var server = new HttpServer(new IPEndPoint(IPAddress.Loopback, 80), typeof(Program).Assembly);
            // server.UnexpectedException += e => Console.WriteLine(e);
            server.Run().Wait();
        }
    }

    [Controller]
    public class TestController
    {
        // GET /Test/Static HTTP/1.1
        public static HttpResponse Static(HttpRequest req)
        {
            // Return any HttpResult (see that class for what's possible)
            return String("Success.");
        }

        // GET /Test/Sync HTTP/1.1
        public HttpResponse Sync(HttpRequest req)
        {
            // Charizard instantiates one controller object per request for instance actions
            return String("Success.");
        }
        
        // GET /Test/Async HTTP/1.1
        public async Task<HttpResponse> Async(HttpRequest req)
        {
            // Async works
            return await Task.FromResult(String("Success."));
        }
        
        // GET /Test/Params?name=Hi&id=12 HTTP/1.1
        public HttpResponse Params(string name, int id)
        {
            // We can use parameters
            return Json(new FooType { Name = name, Id = id });
            
            // Response:
            // Content-Type: application/json
            // { "Name": "Hi", "Id": 12 }
        }
        
        // POST /Test/Post HTTP/1.1
        // POST-Body: 
        // { "Name": "Hello", "Id": 13 }
        public HttpResponse Post(FooType foo) 
        {
            // Post bodies are JSON-encoded, so they are easy to generate
            // from any client-side language. Deep objects are no problems, 
            // anything that can be handled by Newtonsoft.Json is fine. 
            // We don't support HTML-Forms, since they are - on our opionion - outdated. 
            return String("foo.Name: " + foo.Name + " --- foo.Id: " + foo.Id);
        }
        
        // Dummy type for demonstration
        public class FooType
        {
            public string Name { get; set; }
            public int Id { get; set; }
        }
    }
}

StatsHelix.Charizard

The StatsHelix Charizard web framework.

Example

using System;
using System.Net;
using System.Threading.Tasks;

using StatsHelix.Charizard;
using static StatsHelix.Charizard.HttpResponse;

namespace TestApp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var server = new HttpServer(new IPEndPoint(IPAddress.Loopback, 80), typeof(Program).Assembly);
            // server.UnexpectedException += e => Console.WriteLine(e);
            server.Run().Wait();
        }
    }

    [Controller]
    public class TestController
    {
        // GET /Test/Static HTTP/1.1
        public static HttpResponse Static(HttpRequest req)
        {
            // Return any HttpResult (see that class for what's possible)
            return String("Success.");
        }

        // GET /Test/Sync HTTP/1.1
        public HttpResponse Sync(HttpRequest req)
        {
            // Charizard instantiates one controller object per request for instance actions
            return String("Success.");
        }
        
        // GET /Test/Async HTTP/1.1
        public async Task<HttpResponse> Async(HttpRequest req)
        {
            // Async works
            return await Task.FromResult(String("Success."));
        }
        
        // GET /Test/Params?name=Hi&id=12 HTTP/1.1
        public HttpResponse Params(string name, int id)
        {
            // We can use parameters
            return Json(new FooType { Name = name, Id = id });
            
            // Response:
            // Content-Type: application/json
            // { "Name": "Hi", "Id": 12 }
        }
        
        // POST /Test/Post HTTP/1.1
        // POST-Body: 
        // { "Name": "Hello", "Id": 13 }
        public HttpResponse Post(FooType foo) 
        {
            // Post bodies are JSON-encoded, so they are easy to generate
            // from any client-side language. Deep objects are no problems, 
            // anything that can be handled by Newtonsoft.Json is fine. 
            // We don't support HTML-Forms, since they are - on our opionion - outdated. 
            return String("foo.Name: " + foo.Name + " --- foo.Id: " + foo.Id);
        }
        
        // Dummy type for demonstration
        public class FooType
        {
            public string Name { get; set; }
            public int Id { get; set; }
        }
    }
}

Release Notes

Add PageNotFound-Handler that handles 404s

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.10.3 200 12/29/2018
0.10.2 147 12/29/2018
0.10.1 145 12/27/2018
0.9.5 280 2/11/2018
0.9.2 302 7/7/2017
0.9.1 245 7/7/2017
0.9.0 305 5/12/2017