Skip to content

Commit a393d2b

Browse files
authored
Examples: Add a Hello World example using Hummingbird (#3)
### Motivation Having simple "getting started" examples is helpful for new users. Some users may be more familiar with Hummingbird instead of Vapor. ### Modifications Adds another example, using Hummingbird, and links it into the documentation. ### Result New users who want to use Hummingbird can start from a tested starting point. ### Test Plan Built and deployed the example locally, and ran the soundness checks.
1 parent 3383c16 commit a393d2b

File tree

6 files changed

+274
-1
lines changed

6 files changed

+274
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"originHash" : "2f3ac8faf8689600adc30e65a0df976a76c71e7a7eab1e21727045478315c6d6",
3+
"pins" : [
4+
{
5+
"identity" : "async-http-client",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/swift-server/async-http-client.git",
8+
"state" : {
9+
"revision" : "64abc77edf1ef81e69bd90a2ac386de615c8e8ea",
10+
"version" : "1.23.0"
11+
}
12+
},
13+
{
14+
"identity" : "hummingbird",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/hummingbird-project/hummingbird.git",
17+
"state" : {
18+
"revision" : "913e6a0b4bd9c1c0efd399cd870c47187e74d00e",
19+
"version" : "2.1.0"
20+
}
21+
},
22+
{
23+
"identity" : "swift-algorithms",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/apple/swift-algorithms.git",
26+
"state" : {
27+
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
28+
"version" : "1.2.0"
29+
}
30+
},
31+
{
32+
"identity" : "swift-argument-parser",
33+
"kind" : "remoteSourceControl",
34+
"location" : "https://github.com/apple/swift-argument-parser",
35+
"state" : {
36+
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
37+
"version" : "1.5.0"
38+
}
39+
},
40+
{
41+
"identity" : "swift-async-algorithms",
42+
"kind" : "remoteSourceControl",
43+
"location" : "https://github.com/apple/swift-async-algorithms.git",
44+
"state" : {
45+
"revision" : "6ae9a051f76b81cc668305ceed5b0e0a7fd93d20",
46+
"version" : "1.0.1"
47+
}
48+
},
49+
{
50+
"identity" : "swift-atomics",
51+
"kind" : "remoteSourceControl",
52+
"location" : "https://github.com/apple/swift-atomics.git",
53+
"state" : {
54+
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
55+
"version" : "1.2.0"
56+
}
57+
},
58+
{
59+
"identity" : "swift-collections",
60+
"kind" : "remoteSourceControl",
61+
"location" : "https://github.com/apple/swift-collections.git",
62+
"state" : {
63+
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
64+
"version" : "1.1.4"
65+
}
66+
},
67+
{
68+
"identity" : "swift-container-plugin",
69+
"kind" : "remoteSourceControl",
70+
"location" : "https://github.com/apple/swift-container-plugin",
71+
"state" : {
72+
"revision" : "5b6a2583cbc9109c77795cd4eaf94b4a1e88f7eb",
73+
"version" : "0.1.0"
74+
}
75+
},
76+
{
77+
"identity" : "swift-crypto",
78+
"kind" : "remoteSourceControl",
79+
"location" : "https://github.com/apple/swift-crypto.git",
80+
"state" : {
81+
"revision" : "ffca28be3c9c6a86a579949d23f68818a4b9b5d8",
82+
"version" : "3.8.0"
83+
}
84+
},
85+
{
86+
"identity" : "swift-distributed-tracing",
87+
"kind" : "remoteSourceControl",
88+
"location" : "https://github.com/apple/swift-distributed-tracing.git",
89+
"state" : {
90+
"revision" : "11c756c5c4d7de0eeed8595695cadd7fa107aa19",
91+
"version" : "1.1.1"
92+
}
93+
},
94+
{
95+
"identity" : "swift-http-types",
96+
"kind" : "remoteSourceControl",
97+
"location" : "https://github.com/apple/swift-http-types.git",
98+
"state" : {
99+
"revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd",
100+
"version" : "1.3.0"
101+
}
102+
},
103+
{
104+
"identity" : "swift-log",
105+
"kind" : "remoteSourceControl",
106+
"location" : "https://github.com/apple/swift-log.git",
107+
"state" : {
108+
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
109+
"version" : "1.6.1"
110+
}
111+
},
112+
{
113+
"identity" : "swift-metrics",
114+
"kind" : "remoteSourceControl",
115+
"location" : "https://github.com/apple/swift-metrics.git",
116+
"state" : {
117+
"revision" : "e0165b53d49b413dd987526b641e05e246782685",
118+
"version" : "2.5.0"
119+
}
120+
},
121+
{
122+
"identity" : "swift-nio",
123+
"kind" : "remoteSourceControl",
124+
"location" : "https://github.com/apple/swift-nio.git",
125+
"state" : {
126+
"revision" : "665206000b8307cab5ac51203d29b0f232d7e31b",
127+
"version" : "2.74.0"
128+
}
129+
},
130+
{
131+
"identity" : "swift-nio-extras",
132+
"kind" : "remoteSourceControl",
133+
"location" : "https://github.com/apple/swift-nio-extras.git",
134+
"state" : {
135+
"revision" : "d1ead62745cc3269e482f1c51f27608057174379",
136+
"version" : "1.24.0"
137+
}
138+
},
139+
{
140+
"identity" : "swift-nio-http2",
141+
"kind" : "remoteSourceControl",
142+
"location" : "https://github.com/apple/swift-nio-http2.git",
143+
"state" : {
144+
"revision" : "b5f7062b60e4add1e8c343ba4eb8da2e324b3a94",
145+
"version" : "1.34.0"
146+
}
147+
},
148+
{
149+
"identity" : "swift-nio-ssl",
150+
"kind" : "remoteSourceControl",
151+
"location" : "https://github.com/apple/swift-nio-ssl.git",
152+
"state" : {
153+
"revision" : "7b84abbdcef69cc3be6573ac12440220789dcd69",
154+
"version" : "2.27.2"
155+
}
156+
},
157+
{
158+
"identity" : "swift-nio-transport-services",
159+
"kind" : "remoteSourceControl",
160+
"location" : "https://github.com/apple/swift-nio-transport-services.git",
161+
"state" : {
162+
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
163+
"version" : "1.21.0"
164+
}
165+
},
166+
{
167+
"identity" : "swift-numerics",
168+
"kind" : "remoteSourceControl",
169+
"location" : "https://github.com/apple/swift-numerics.git",
170+
"state" : {
171+
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
172+
"version" : "1.0.2"
173+
}
174+
},
175+
{
176+
"identity" : "swift-service-context",
177+
"kind" : "remoteSourceControl",
178+
"location" : "https://github.com/apple/swift-service-context.git",
179+
"state" : {
180+
"revision" : "0c62c5b4601d6c125050b5c3a97f20cce881d32b",
181+
"version" : "1.1.0"
182+
}
183+
},
184+
{
185+
"identity" : "swift-service-lifecycle",
186+
"kind" : "remoteSourceControl",
187+
"location" : "https://github.com/swift-server/swift-service-lifecycle.git",
188+
"state" : {
189+
"revision" : "24c800fb494fbee6e42bc156dc94232dc08971af",
190+
"version" : "2.6.1"
191+
}
192+
},
193+
{
194+
"identity" : "swift-system",
195+
"kind" : "remoteSourceControl",
196+
"location" : "https://github.com/apple/swift-system.git",
197+
"state" : {
198+
"revision" : "d2ba781702a1d8285419c15ee62fd734a9437ff5",
199+
"version" : "1.3.2"
200+
}
201+
}
202+
],
203+
"version" : 3
204+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// swift-tools-version: 6.0
2+
3+
//===----------------------------------------------------------------------===//
4+
//
5+
// This source file is part of the SwiftContainerPlugin open source project
6+
//
7+
// Copyright (c) 2024 Apple Inc. and the SwiftContainerPlugin project authors
8+
// Licensed under Apache License v2.0
9+
//
10+
// See LICENSE.txt for license information
11+
// See CONTRIBUTORS.txt for the list of SwiftContainerPlugin project authors
12+
//
13+
// SPDX-License-Identifier: Apache-2.0
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
import PackageDescription
18+
19+
let package = Package(
20+
name: "hello-world",
21+
platforms: [.macOS(.v14)],
22+
dependencies: [
23+
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.1.0"),
24+
.package(url: "https://github.com/apple/swift-container-plugin", from: "0.1.0"),
25+
],
26+
targets: [
27+
.executableTarget(name: "hello-world", dependencies: [.product(name: "Hummingbird", package: "hummingbird")])
28+
]
29+
30+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the SwiftContainerPlugin open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the SwiftContainerPlugin project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of SwiftContainerPlugin project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
import Foundation
16+
import Hummingbird
17+
18+
let myos = ProcessInfo.processInfo.operatingSystemVersionString
19+
20+
let router = Router()
21+
router.get { request, _ -> String in "Hello World, from Hummingbird on \(myos)\n" }
22+
23+
let app = Application(router: router, configuration: .init(address: .hostname("0.0.0.0", port: 8080)))
24+
25+
try await app.runService()

Examples/HelloWorldVapor/Sources/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ let app = try Application(.detect())
2121
app.http.server.configuration.hostname = "0.0.0.0"
2222
defer { app.shutdown() }
2323

24-
app.get { _ in "Hello World, from \(myos)\n" }
24+
app.get { _ in "Hello World, from Vapor on \(myos)\n" }
2525

2626
try app.run()

NOTICE.txt

+6
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,9 @@ following other projects:
7272
* https://mit-license.org
7373
* HOMEPAGE:
7474
* https://github.com/vapor/vapor
75+
76+
* Hummingbird
77+
* LICENSE (Apache License 2.0):
78+
* https://www.apache.org/licenses/LICENSE-2.0
79+
* HOMEPAGE:
80+
* https://github.com/hummingbird-project/hummingbird

0 commit comments

Comments
 (0)