⚡
Zero Dependencies, Maximum Speed
Built on top of native sockets. Minimal overhead, instant startup and strong performance under load.
Designed for Simplicity. Built for Speed.
Built on top of native sockets. Minimal overhead, instant startup and strong performance under load.
Handle APIs, static files, and dynamic content through a simple routing model — with full control over behavior.
A fully integrated core designed for real-world usage, covering security, communication, and observability without external dependencies.
Designed for extensibility. Integrate additional capabilities through independent modules without bloating your core.
Start with a few lines of code, then add controllers, addons, and hosting features as your application grows.
// debug log
Log.SetSink(Log.ConsoleWriteLine, LogLevel.Debug);
// listen to all IPs port 8080
var server = new SimpleWServer(IPAddress.Any, 8080);
// map handler to a route
server.MapGet("/api/test/hello", () => {
return new { message = "Hello World !" };
});
// run server
await server.RunAsync();class Program {
static async Task Main() {
// server
await new SimpleWServer(IPAddress.Any, 8080)
.MapControllers<Controller>("/api")
.RunAsync();
}
}
public class TestController : Controller {
// handler
[Route("GET", "/test")]
public object Hello(string name) {
return new { message = $"{name}, Hello World !" };
}
}class Program {
static async Task Main() {
var server = new SimpleWServer(IPAddress.Any, 8080);
// telemetry
server.ConfigureTelemetry(options => {
options.IncludeStackTrace = true;
});
// socket tuning
server.Configure(options => {
options.TcpNoDelay = true;
options.ReuseAddress = true;
options.TcpKeepAlive = true;
});
// find all classes based on Controller class, and serve on the "/api" endpoint
server.MapControllers<Controller>("/api");
// static files with cache
server.UseStaticFilesModule(options => {
options.Path = "/app/www/public";
options.CacheTimeout = TimeSpan.FromDays(1);
});
// Firewall
server.UseFirewallModule(options => {
options.AllowRules.Add(IpRule.Cidr("10.0.0.0/8"));
options.AllowRules.Add(IpRule.Single("127.0.0.1"));
options.MaxMindCountryDbPath = "/app/data/GeoLite2-Country.mmdb";
options.AllowCountries.Add(CountryRule.Any("FR"));
});
// OpenID
server.UseOpenIDModule(options => {
options.Add("google", o => {
o.Authority = "https://accounts.google.com";
o.ClientId = "<google-client-id>";
o.ClientSecret = "<google-client-secret>";
o.RedirectUri = "https://myapp.example.com/auth/oidc/callback/google";
});
});
// run server
await server.RunAsync();
}
}
public class TestController : Controller {
// handler
[Route("GET", "/test")]
public object Hello(string name) {
return new { message = $"{name}, Hello World !" };
}
}var builder = SimpleWHost.CreateApplicationBuilder(args)
.UseMicrosoftLogging();
builder.ConfigureSimpleW(server => {
configureApp: server => {
// razor
server.UseRazorModule(options => {
options.ViewsPath = "Views";
});
// OpenAPI JSON
server.MapGet("/swagger.json", static (HttpSession session) => {
return Swagger.Json(session);
});
// Swagger UI
server.MapGet("/swagger", static (HttpSession session) => {
return Swagger.UI(session);
});
// routes
server.MapGet("/hello", () => {
return new { message = "Hello World !" };
});
// ssl
X509Certificate2 cert = new(@"/app/ssl/domain.pfx", "password");
var sslcontext = new SslContext(SslProtocols.Tls12 | SslProtocols.Tls13, cert, clientCertificateRequired: false, checkCertificateRevocation: false);
server.UseHttps(sslcontext);
},
configureServer: options => {
options.TcpNoDelay = true;
options.ReuseAddress = true;
options.TcpKeepAlive = true;
}
});
var host = builder.Build();
await host.RunAsync();