Skip to content

Commit ce7fa84

Browse files
committed
Deprecate JSONPredicatePattern
1 parent e9cbdeb commit ce7fa84

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

FlyingFox/Sources/JSONPredicatePattern.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import Foundation
3535

36+
@available(*, deprecated, message: "Use JSONBodyPattern")
3637
public struct JSONPredicatePattern: HTTPBodyPattern {
3738

3839
#if compiler(>=6)
@@ -55,8 +56,10 @@ public struct JSONPredicatePattern: HTTPBodyPattern {
5556
}
5657
}
5758

59+
@available(*, deprecated, message: "Use JSONBodyPattern")
5860
public extension HTTPBodyPattern where Self == JSONPredicatePattern {
5961

62+
@available(*, deprecated, message: "Use JSONBodyPattern")
6063
static func json(where condition: String) -> JSONPredicatePattern {
6164
JSONPredicatePattern(NSPredicate(format: condition))
6265
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,13 @@ public protocol HTTPBodyPattern: Sendable {
302302
}
303303
```
304304

305-
Darwin platforms can pattern match a JSON body with an [`NSPredicate`](https://developer.apple.com/documentation/foundation/nspredicate):
305+
JSON request bodies can be matched using a [JSONPath](https://en.wikipedia.org/wiki/JSONPath) expression:
306306

307307
```swift
308-
let route = HTTPRoute("POST *", body: .json(where: "food == 'fish'"))
308+
let route = HTTPRoute(
309+
"POST *",
310+
jsonBody: { $0["$.food"] == "chips" }
311+
)
309312
```
310313
```json
311314
{"side": "chips", "food": "fish"}

0 commit comments

Comments
 (0)