{"id":22466296,"url":"https://github.com/hummingbird-project/hummingbird-core","last_synced_at":"2025-05-08T21:17:43.199Z","repository":{"id":43886280,"uuid":"334920248","full_name":"hummingbird-project/hummingbird-core","owner":"hummingbird-project","description":"HTTP server for Hummingbird the lightweight, flexible web application framework written in Swift ","archived":false,"fork":false,"pushed_at":"2024-09-03T08:32:16.000Z","size":517,"stargazers_count":44,"open_issues_count":1,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-08T21:17:22.947Z","etag":null,"topics":["http-server","http2","server","server-side-swift","swift-nio","tls"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hummingbird-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"adam-fowler"}},"created_at":"2021-02-01T10:59:56.000Z","updated_at":"2025-03-04T00:37:45.000Z","dependencies_parsed_at":"2024-04-18T15:55:06.386Z","dependency_job_id":"6b498d05-d81c-4abb-9003-eb22895381fb","html_url":"https://github.com/hummingbird-project/hummingbird-core","commit_stats":{"total_commits":109,"total_committers":2,"mean_commits":54.5,"dds":0.00917431192660545,"last_synced_commit":"30851c0774f341db00656c8112c9205ae2f605ce"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hummingbird-project%2Fhummingbird-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hummingbird-project%2Fhummingbird-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hummingbird-project%2Fhummingbird-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hummingbird-project%2Fhummingbird-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hummingbird-project","download_url":"https://codeload.github.com/hummingbird-project/hummingbird-core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149622,"owners_count":21861740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-server","http2","server","server-side-swift","swift-nio","tls"],"created_at":"2024-12-06T10:11:31.023Z","updated_at":"2025-05-08T21:17:43.179Z","avatar_url":"https://github.com/hummingbird-project.png","language":"Swift","funding_links":["https://github.com/sponsors/adam-fowler"],"categories":[],"sub_categories":[],"readme":"# HummingbirdCore\n\nSwift NIO based HTTP server. The core HTTP server component for v1.0 of the [Hummingbird](https://github.com/hummingbird-project/hummingbird) web framework. \n\n## Usage\n\nHummingbirdCore contains a Swift NIO based HTTP server. When starting the server you provide it with a struct that conforms to `HBHTTPResponder` to define how the server should respond to requests. For example the following is a responder that always returns a response containing the word \"Hello\" in the body. \n\n```swift\nstruct HelloResponder: HBHTTPResponder {\n    func respond(to request: HBHTTPRequest, context: ChannelHandlerContext, onComplete: @escaping (Result\u003cHBHTTPResponse, Error\u003e) -\u003e Void) {\n        let responseHead = HTTPResponseHead(version: .init(major: 1, minor: 1), status: .ok)\n        let responseBody = context.channel.allocator.buffer(string: \"Hello\")\n        let response = HBHTTPResponse(head: responseHead, body: .byteBuffer(responseBody))\n        onComplete(.success(response))\n    }\n}\n```\n\nThe following will start up a server using the above `HelloResponder`.\n\n```swift\nlet eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)\nlet server = HBHTTPServer(\n    group: eventLoopGroup, \n    configuration: .init(address: .hostname(\"127.0.0.1\", port: 8080))\n)\ntry server.start(responder: HelloResponder()).wait()\n// Wait until server closes which never happens as server channel is never closed\ntry server.wait()\n```\n\n## Swift service lifecycle\n\nIf you are using HummingbirdCore outside of Hummingbird ideally you would use it along with the swift-server library [swift-service-lifecycle](https://github.com/swift-server/swift-service-lifecycle). This gives you a framework for clean initialization and shutdown of your server. The following sets up a Lifecycle that initializes the HTTP server and stops it when the application shuts down.\n```swift\nimport Lifecycle\nimport LifecycleNIOCompat\n\nlet lifecycle = ServiceLifecycle()\nlifecycle.register(\n    label: \"HTTP Server\",\n    start: .eventLoopFuture { self.server.start(responder: MyResponder()) },\n    shutdown: .eventLoopFuture(self.server.stop)\n)\nlifecycle.start { error in\n    if let error = error {\n        print(\"ERROR: \\(error)\")\n    }\n}\nlifecycle.wait()\n```\n\n## HummingbirdCore Extensions\n\nThe HummingbirdCore can be extended to support TLS and HTTP2 via the HummingbirdTLS and HummingbirdHTTP2 libraries. The following will add TLS support\n```swift\nimport HummingbirdTLS\nserver.addTLS(tlsConfiguration: myTLSConfiguration)\n```\nand this will add an HTTP2 upgrade option\n```swift\nimport HummingbirdHTTP2\nserver.addHTTP2Upgrade(tlsConfiguration: myTLSConfiguration)\n```\nAs the HTTP2 upgrade requires a TLS connection this is added automatically when enabling HTTP2 upgrade. So don't call both function as this will setup two TLS handlers.\n\n## Documentation\n\nReference documentation for both HummingbirdCore and Hummingbird can be found [here](https://hummingbird-project.github.io/hummingbird-docs/1.0/documentation/hummingbirdcore)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhummingbird-project%2Fhummingbird-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhummingbird-project%2Fhummingbird-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhummingbird-project%2Fhummingbird-core/lists"}