Skip to content

Commit

Permalink
added module for HTMX WS extension (#9)
Browse files Browse the repository at this point in the history
* implemented HTMX WebSockets

* implemented HTMXWS in HummingbirdDemo

* implemented HTMXWS in VaporDemo

* updated README.md

* fixed tests not up to date

* updated Package.swift

* removed print and URLPrefixes

* improved Hummingbird example

* improved Vapor example

* updated README.md with SSE and WS extensions

* fixed tests
  • Loading branch information
h0p3zZ authored Oct 3, 2024
1 parent f20ae43 commit 40ab433
Show file tree
Hide file tree
Showing 20 changed files with 1,134 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Examples/HummingbirdDemo/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird-websocket.git", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-community/hummingbird-elementary.git", from: "0.2.0-rc.1"),
.package(path: "../../"),
.package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"),
Expand All @@ -21,9 +22,12 @@ let package = Package(
name: "App",
dependencies: [
.product(name: "Hummingbird", package: "hummingbird"),
.product(name: "HummingbirdWebSocket", package: "hummingbird-websocket"),
.product(name: "HummingbirdWSCompression", package: "hummingbird-websocket"),
.product(name: "HummingbirdElementary", package: "hummingbird-elementary"),
.product(name: "ElementaryHTMX", package: "elementary-htmx"),
.product(name: "ElementaryHTMXSSE", package: "elementary-htmx"),
.product(name: "ElementaryHTMXWS", package: "elementary-htmx"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
],
Expand Down
6 changes: 6 additions & 0 deletions Examples/HummingbirdDemo/Sources/App/App.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
import Hummingbird
import HummingbirdWebSocket
import HummingbirdWSCompression

@main
struct App {
Expand All @@ -11,8 +13,12 @@ struct App {

addRoutes(to: router)

let wsRouter = Router(context: BasicWebSocketRequestContext.self)
addWSRoutes(to: wsRouter)

let app = Application(
router: router,
server: .http1WebSocketUpgrade(webSocketRouter: wsRouter, configuration: .init(extensions: [.perMessageDeflate()])),
onServerRunning: { _ in
print("Server running on http://localhost:8080/")
#if DEBUG
Expand Down
Loading

0 comments on commit 40ab433

Please sign in to comment.