Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swift/hummingbird-framwork to use Hummingbird v2 #7806

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions swift/hummingbird-framework/Package.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
// swift-tools-version:5.3
// swift-tools-version:5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "server",
products: [
.executable(name: "server", targets: ["server"])
],
platforms: [.macOS(.v14)], // This is for development on macOS
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", .upToNextMinor(from: "1.0.0")),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", .upToNextMinor(from: "2.0.0")),
],
targets: [
.target(name: "server",
.executableTarget(
name: "server",
dependencies: [
.product(name: "Hummingbird", package: "hummingbird"),
],
Expand Down
30 changes: 30 additions & 0 deletions swift/hummingbird-framework/Sources/server/Server.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Hummingbird

@main
struct Server {
static func main() async throws {
let env = Environment()
let serverHostName = env.get("SERVER_HOSTNAME") ?? "127.0.0.1"
let serverPort = env.get("SERVER_PORT", as: Int.self) ?? 8080

let router = Router()
router.get("/") { _, _ in
HTTPResponse.Status.ok
}

router.get("user/:id") { _, ctx -> String in
ctx.parameters.get("id") ?? ""
}

router.post("user") { _, _ in
HTTPResponse.Status.ok
}

let app = Application(
router: router,
configuration: .init(address: .hostname(serverHostName, port: serverPort))
)

try await app.run()
}
}
30 changes: 0 additions & 30 deletions swift/hummingbird-framework/Sources/server/main.swift

This file was deleted.

2 changes: 1 addition & 1 deletion swift/hummingbird-framework/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
framework:
github: hummingbird-project/hummingbird
version: 1.0
version: 2.0
name: hummingbird

environment:
Expand Down
Loading