Skip to content

Commit 424111e

Browse files
committed
Get rid of FlyingFoxMacros
It just keeps messing up the build
1 parent 1161667 commit 424111e

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ let package = Package(
4040

4141
.package(url: "https://github.com/livekit/webrtc-xcframework.git", exact: "137.7151.07"),
4242
.package(url: "https://github.com/swhitty/FlyingFox.git", .upToNextMajor(from: "0.25.0")),
43-
.package(url: "https://github.com/swhitty/FlyingFoxMacros.git", .upToNextMajor(from: "0.2.0")),
4443

4544
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
4645
.package(url: "https://github.com/alloverse/OpenCombine.git", branch: "fix/vision-support"), // So we can use Combine on Linux.
@@ -58,7 +57,6 @@ let package = Package(
5857
dependencies: [
5958
"PotentCodables",
6059
"FlyingFox",
61-
"FlyingFoxMacros",
6260
"Version",
6361
.product(name: "kvSIMD", package: "kvSIMD.swift"),
6462
.product(name: "SIMDTools", package:"simd-tools"),

Sources/allonet2/PlaceServer/PlaceServerHTTP.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import Foundation
99
import FlyingFox
10-
import FlyingFoxMacros
1110

1211
public struct AppDescription
1312
{
@@ -19,7 +18,6 @@ public struct AppDescription
1918
}
2019

2120
@MainActor
22-
@HTTPHandler
2321
class PlaceServerHTTP
2422
{
2523
private var http: HTTPServer! = nil
@@ -37,10 +35,11 @@ class PlaceServerHTTP
3735
}
3836
func start() async throws
3937
{
40-
self.http = HTTPServer(port: port, handler: self)
41-
// Routes are also added with @HTTPRoute/@JSONRoute, see below.
38+
self.http = HTTPServer(port: port)
39+
await self.http.appendRoute("GET /") { return try await self.landingPage($0) }
40+
await self.http.appendRoute("POST /") { return try await self.handleIncomingClient($0) }
4241
try await self.status.start(on: http)
43-
42+
4443
try await http.start()
4544
}
4645

@@ -49,7 +48,6 @@ class PlaceServerHTTP
4948
await http.stop()
5049
}
5150

52-
@HTTPRoute("GET /")
5351
func landingPage(_ request: HTTPRequest) async -> HTTPResponse
5452
{
5553
let host = request.headers[.host] ?? "localhost"
@@ -97,8 +95,7 @@ class PlaceServerHTTP
9795
)
9896
}
9997

100-
@JSONRoute("POST /")
101-
func handleIncomingClient(_ request: HTTPRequest) async throws -> SignallingPayload
98+
func handleIncomingClient(_ request: HTTPRequest) async throws -> HTTPResponse
10299
{
103100
let offer = try await JSONDecoder().decode(SignallingPayload.self, from: request.bodyData)
104101

@@ -115,6 +112,10 @@ class PlaceServerHTTP
115112
let response = try await session.generateAnswer(offer: offer)
116113
client.logger.info("Client is \(session.clientId!), sending answer...")
117114

118-
return response
115+
return HTTPResponse(
116+
statusCode: .ok,
117+
headers: [.contentType: "application/json"],
118+
body: try await JSONEncoder().encode(response)
119+
)
119120
}
120121
}

Sources/allonet2/PlaceServer/PlaceServerStatus.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
import Foundation
99
import FlyingFox
10-
import FlyingFoxMacros
1110

1211
@MainActor
13-
@HTTPHandler
1412
class PlaceServerStatus: WSMessageHandler
1513
{
1614
weak var server: PlaceServer!
@@ -24,13 +22,16 @@ class PlaceServerStatus: WSMessageHandler
2422

2523
func start(on http: HTTPServer) async throws
2624
{
27-
await http.appendRoute("GET /dashboard", to: self)
28-
await http.appendRoute("GET /dashboard/*", to: self)
25+
await http.appendRoute("GET /dashboard") {
26+
return await self.index($0)
27+
}
28+
await http.appendRoute("GET /dashboard/logs") {
29+
return await self.logs($0)
30+
}
2931
await http.appendRoute("GET /dashboard/logs/follow", to: .webSocket(self))
3032
}
3133

3234
// MARK: Status page
33-
@HTTPRoute("dashboard")
3435
func index(_ request: HTTPRequest) async -> HTTPResponse
3536
{
3637
let body = """
@@ -328,7 +329,6 @@ class PlaceServerStatus: WSMessageHandler
328329
}
329330

330331
// - MARK: Logs
331-
@HTTPRoute("dashboard/logs")
332332
func logs(_ request: HTTPRequest) async -> HTTPResponse
333333
{
334334
let body = """

0 commit comments

Comments
 (0)