Last active
December 11, 2020 09:49
-
-
Save Alexander-Ignition/595a80951b3a4d1cb8f063b0ceecf48c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ServerRoute { | |
| typealias Handler = (_ request: Request, _ count: Int) -> Response? | |
| enum Method: String { | |
| case GET, POST | |
| } | |
| let method: Method | |
| let pattern: String | |
| let handler: Handler | |
| var uri: String { "\(method.rawValue) \(pattern)" } | |
| } | |
| @available(iOS 12.0, *) | |
| extension StubServer { | |
| /// Add server route. | |
| /// | |
| /// server.add(Stabs.Billing.bookingPaymentAlreadyActivated) | |
| /// | |
| func add(_ route: ServerRoute) { | |
| addHandler(route.uri, route.handler) | |
| } | |
| } | |
| enum Stabs { | |
| enum Billing {} | |
| } | |
| extension Stabs.Billing { | |
| /// Skip booking payment | |
| static var bookingPaymentAlreadyActivated: ServerRoute { | |
| ServerRoute(method: .POST, pattern: "/billing/booking/payment/init") { _, _ in | |
| Response.badResponse(code: .productAlreadyActivated) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment