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
Lines changed: 8 additions & 0 deletions
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

Examples/HelloWorldHummingbird/Package.resolved

Lines changed: 204 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
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+
)
Lines changed: 30 additions & 0 deletions
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)