diff --git a/.github/workflows/api-docs.yml b/.github/workflows/api-docs.yml
index e90c85ea..fbfd381c 100644
--- a/.github/workflows/api-docs.yml
+++ b/.github/workflows/api-docs.yml
@@ -11,4 +11,4 @@ jobs:
with:
package_name: routing-kit
modules: RoutingKit
- pathsToInvalidate: /routing-kit
\ No newline at end of file
+ pathsToInvalidate: /routingkit/*
diff --git a/.github/workflows/main-codecov.yml b/.github/workflows/main-codecov.yml
deleted file mode 100644
index 1d0fe384..00000000
--- a/.github/workflows/main-codecov.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-name: Update code coverage baselines
-on:
- push: { branches: [ main ] }
-jobs:
- update-main-codecov:
- uses: vapor/ci/.github/workflows/run-unit-tests.yml@reusable-workflows
- with:
- with_coverage: true
- with_tsan: true
diff --git a/.github/workflows/projectboard.yml b/.github/workflows/projectboard.yml
index a0e6d988..8c8f4bd9 100644
--- a/.github/workflows/projectboard.yml
+++ b/.github/workflows/projectboard.yml
@@ -7,5 +7,5 @@ on:
jobs:
update_project_boards:
name: Update project boards
- uses: vapor/ci/.github/workflows/update-project-boards-for-issue.yml@reusable-workflows
+ uses: vapor/ci/.github/workflows/update-project-boards-for-issue.yml@main
secrets: inherit
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b4c3e331..647e6eac 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -3,10 +3,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
- pull_request: { branches: ['*'] }
- push: { branches: ['main'] }
-
-
+ pull_request: { types: [opened, reopened, synchronize, ready_for_review] }
+ push: { branches: [ main ] }
env:
LOG_LEVEL: info
SWIFT_DETERMINISTIC_HASHING: 1
@@ -14,13 +12,11 @@ env:
jobs:
unit-tests:
- uses: vapor/ci/.github/workflows/run-unit-tests.yml@reusable-workflows
- with:
- with_coverage: true
+ uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
upstream-check:
runs-on: ubuntu-latest
- container: swift:5.7-jammy
+ container: swift:5.8-jammy
steps:
- name: Check out self
uses: actions/checkout@v3
diff --git a/Package.swift b/Package.swift
index d70318ef..f17e4b45 100644
--- a/Package.swift
+++ b/Package.swift
@@ -1,4 +1,4 @@
-// swift-tools-version:5.5.2
+// swift-tools-version:5.6
import PackageDescription
let package = Package(
@@ -13,7 +13,7 @@ let package = Package(
.library(name: "RoutingKit", targets: ["RoutingKit"]),
],
dependencies: [
- .package(url: "https://github.com/apple/swift-log.git", from: "1.4.2")
+ .package(url: "https://github.com/apple/swift-log.git", from: "1.5.3")
],
targets: [
.target(name: "RoutingKit", dependencies: [
diff --git a/README.md b/README.md
index 6ff74b9d..6bc92899 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,15 @@
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/Sources/RoutingKit/AnyRouter.swift b/Sources/RoutingKit/AnyRouter.swift
index 0ecbd766..5fe9f8cc 100644
--- a/Sources/RoutingKit/AnyRouter.swift
+++ b/Sources/RoutingKit/AnyRouter.swift
@@ -1,4 +1,5 @@
/// A router that performs type erasure by wrapping another router.
+@available(*, deprecated, message: "This type is no longer useful in Swift 5.7")
public struct AnyRouter: Router {
private let box: _AnyRouterBase
@@ -17,6 +18,7 @@ public struct AnyRouter: Router {
extension Router {
/// Wraps this router with a type eraser.
+ @available(*, deprecated, message: "This method is no longer useful in Swift 5.7")
public func eraseToAnyRouter() -> AnyRouter {
return AnyRouter(self)
}
diff --git a/Sources/RoutingKit/Parameters.swift b/Sources/RoutingKit/Parameters.swift
index fd973c99..d885fb57 100644
--- a/Sources/RoutingKit/Parameters.swift
+++ b/Sources/RoutingKit/Parameters.swift
@@ -23,7 +23,7 @@ public struct Parameters {
public init() {
self.values = [:]
self.catchall = Catchall()
- self.logger = Logger(label: "routing-kit-parameters-logger")
+ self.logger = Logger(label: "codes.vapor.routingkit")
}
/// Creates a new `Parameters`.
@@ -33,7 +33,7 @@ public struct Parameters {
public init(_ logger: Logger?) {
self.values = [:]
self.catchall = Catchall()
- self.logger = logger ?? Logger(label: "routing-kit-parameters-logger")
+ self.logger = logger ?? Logger(label: "codes.vapor.routingkit")
}
/// Grabs the named parameter from the parameter bag.
diff --git a/Sources/RoutingKit/TrieRouter.swift b/Sources/RoutingKit/TrieRouter.swift
index c292ab7e..fa2c30b7 100644
--- a/Sources/RoutingKit/TrieRouter.swift
+++ b/Sources/RoutingKit/TrieRouter.swift
@@ -1,3 +1,5 @@
+import Logging
+
/// Generic `TrieRouter` built using the "trie" tree algorithm.
///
/// Use `register(...)` to register routes into the router. Use `route(...)` to then fetch a matching
@@ -17,6 +19,9 @@ public final class TrieRouter: Router, CustomStringConvertible {
/// The root node.
private var root: Node
+
+ /// Configured logger.
+ public let logger: Logger
/// Create a new `TrieRouter`.
///
@@ -25,6 +30,14 @@ public final class TrieRouter: Router, CustomStringConvertible {
public init(_ type: Output.Type = Output.self, options: Set = []) {
self.root = Node()
self.options = options
+ self.logger = .init(label: "codes.vapor.routingkit")
+ }
+
+ /// Create a new `TrieRouter`.
+ public init(_ type: Output.Type = Output.self, options: Set = [], logger: Logger) {
+ self.root = Node()
+ self.options = options
+ self.logger = logger
}
/// Registers a new `Route` to this router.
@@ -53,7 +66,7 @@ public final class TrieRouter: Router, CustomStringConvertible {
// if this node already has output, we are overriding a route
if current.output != nil {
- print("[Routing] Warning: Overriding route output at: \(path.string)")
+ self.logger.info("[Routing] Overriding route output at: \(path.string)")
}
// after iterating over all path components, we can set the output
diff --git a/Tests/RoutingKitTests/RouterTests.swift b/Tests/RoutingKitTests/RouterTests.swift
index ef6919f6..b5a8fdc0 100644
--- a/Tests/RoutingKitTests/RouterTests.swift
+++ b/Tests/RoutingKitTests/RouterTests.swift
@@ -99,15 +99,6 @@ final class RouterTests: XCTestCase {
var params = Parameters()
XCTAssertEqual(router.route(path: ["fun", "meaning_of_universe"], parameters: ¶ms), 42)
}
-
- func testDocs2() throws {
- let router = TrieRouter(String.self)
- router.register("show_user", at: [.constant("users"), .parameter("user_id")])
-
- var params = Parameters()
- _ = router.route(path: ["users", "42"], parameters: ¶ms)
- print(params)
- }
// https://github.com/vapor/routing/issues/64
func testParameterPercentDecoding() throws {