DEV Community

ben
ben

Posted on

PicoServer : a lightweight web request glue library in the .NET ecosystem.

🛠️ What is PicoServer?

PicoServer is a lightweight web request glue library deeply rooted in the .NET ecosystem. It focuses on "Integration-First, Flexible Embedding" — embed it wherever you need web capabilities.

It runs independently of traditional web servers like IIS or Kestrel, and can be directly embedded into any .NET application to quickly build web APIs. It works out of the box with zero configuration and requires no modifications to your existing business code. Whether you need a lightweight Web API, WebSocket real-time communication, edge computing web services, or a lightweight streaming media server, PicoServer fits perfectly.

📦 Ultra-Small Footprint: The single DLL is only 60kb with no third-party dependencies, achieving ultimate lightweight design.

💡 Extremely Easy to Get Started: Install PicoServer via NuGet, then add just one route to complete your Web API setup.

🔗 Flexible Compatibility: Its glue-like nature integrates seamlessly with other libraries — no need to alter business code in legacy projects.

🛡️ Out-of-the-Box Ready: Built-in default routing, simple Token authentication, and JWT authentication cover most basic scenarios.

🚀 Blazing Fast Performance: Features a fully asynchronous non-blocking architecture, natively supports AOT compilation, boots up in milliseconds, and handles all kinds of gateways with ease.

🌍 Cross-Platform Compatibility: Developed based on .NET Standard 2.0, it supports .NET Framework/Core/5/6+ as well as Linux, Windows, and macOS.

Highly Extensible: Customize (Routing) and (Middleware) to easily implement secondary development and unlock more advanced features.AddRouteAddMiddleware

PicoServer can be used free of charge for both personal and commercial projects.

For more usage methods, please refer to the PicoServer Official Documentation. NuGet Package

C# example

using System.Net;
using PicoServer;

namespace FastTestNamespace
{
    public static class FastTest
    {
        private static readonly WebAPIServer MyAPI = new WebAPIServer();

        public static void Main()
        {
            MyAPI.AddRoute("/", Hello);
            MyAPI.StartServer(); //defult port 8090
            Console.WriteLine("visit:http://127.0.0.1:8090");
            Console.ReadKey();
        }

        private static async Task Hello(HttpListenerRequest request, HttpListenerResponse response)
        {
          await response.WriteAsync("""{"code":1,"msg":"Hello WebAPI"}""");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

VB.NET example

Imports System.Net
Imports PicoServer

Module FastTest
    Private ReadOnly MyAPI As New WebAPIServer
    Sub Main()
        MyAPI.AddRoute("/", AddressOf hello)
        MyAPI.StartServer() 'defult port 8090
        Console.WriteLine("visit:http://127.0.0.1:8090")
        Console.ReadKey()
    End Sub

    Private Async Function hello(request As HttpListenerRequest, response As HttpListenerResponse) As Task
        Await response.WriteAsync(<t>{"code":1,"msg":"Hello WebAPI"}</t>.Value)
    End Function
End Module

Enter fullscreen mode Exit fullscreen mode

Top comments (0)