[Pitch] Hummingbird

Hi,

We would like to pitch what will become v2.0 of Hummingbird to the SSWG incubation process. The beta has just been released and we feel it is ready for submission.

Motivation

HTTP servers/applications come in many forms, they can be simple HTTP1 servers with a few routes, HTTP proxies, file servers to complex servers supporting a number of protocols and talking to many other services.

Providing a solution that covers all of these cases is desirable. But when you build your simple HTTP1 server do you want to be including code for a bunch of protocols and services you are never going to use?

Proposed Solution

Hummingbird is a lightweight, modular, flexible HTTP server framework. It provides a server framework to build lightweight servers but can be extended to support as complex a server as you require. Don't want TLS, HTTP2, WebSockets don't include them. But they are available if you require them.

Hummingbird v2.0 is currently under development and this is what we are proposing. Version 2.0 includes a complete Swift concurrency based solution based off SwiftNIO's NIOAsyncChannel bringing all the benefits of structured concurrency including task cancellation, task local variables and local reasoning. In addition it uses the new HTTP types that Apple recently published and integrates with the recently released structured concurrency based version of ServiceLifecycle.

A simple Hummingbird application involves creating a Router, adding some routes to it

let router = Router()
router.post("hello/{name}") { request, context in
    // extract name from route
    let name = try context.parameters.require("name")
    // return string saying "Hello <name>!". This is converted to a HTTP response
    // with the string as its body
    return "Hello \(name)!"
}

And then creating an Application that uses that router

let app = Application(
    router: router,
    server: .http1(), // server defaults to http1(), but this could also be .tls(.http1()), .http2Upgrade() etc
    configuration: .init(address: .hostname("127.0.0.1", port: 8080))
)
try await app.runService()

Hummingbird supports router middleware, TLS, HTTP2, metrics, tracing, file serving. There are associated packages that provide an authentication framework, integration with Fluent and Redis and WebSockets. You can checkout Hummingbird's documentation for a full details of what it supports.

28 Likes

Another obvious candidate here.

Great simple framework, already using version 2 in production for our small service and so far no issues :+1:

4 Likes