Skip to content

Commit b74261a

Browse files
committed
Examples: Add a Hello World example using Hummingbird
1 parent adc5fbe commit b74261a

File tree

4 files changed

+275
-0
lines changed

4 files changed

+275
-0
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" : "ef5465c0be5825a18e45ec9f03ef8e4ba3a99ab0a7eebbda27dfbc180387f766",
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" : "11205411bb60612f0a1a04f733fa71b4fb864ab9",
10+
"version" : "1.22.1"
11+
}
12+
},
13+
{
14+
"identity" : "hummingbird",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/hummingbird-project/hummingbird.git",
17+
"state" : {
18+
"revision" : "d4f792d209f02b26a17c0105751220da65207fb2",
19+
"version" : "2.0.1"
20+
}
21+
},
22+
{
23+
"identity" : "swift-algorithms",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/apple/swift-algorithms",
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" : "81bee98e706aee68d39ed5996db069ef2b313d62",
82+
"version" : "3.7.1"
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" : "1b33db2dea6a64d5b619b9e888175133c6d7f410",
127+
"version" : "2.73.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,33 @@
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.0.0"),
24+
.package(url: "https://github.com/apple/swift-container-plugin", from: "0.1.0"),
25+
],
26+
targets: [
27+
.executableTarget(
28+
name: "hello-world",
29+
dependencies: [.product(name: "Hummingbird", package: "hummingbird")]
30+
),
31+
]
32+
33+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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
22+
return "Hello World, from Hummingbird on \(myos)\n"
23+
}
24+
25+
let app = Application(
26+
router: router,
27+
configuration: .init(address: .hostname("0.0.0.0", port: 8080))
28+
)
29+
30+
try await app.runService()

0 commit comments

Comments
 (0)