2019-12-31 16:40:56 +00:00
|
|
|
//
|
|
|
|
// DelegatingResponse.swift
|
|
|
|
// TuskerUITests
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 12/31/19.
|
|
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Ambassador
|
|
|
|
|
|
|
|
struct DelegatingResponse: WebApp {
|
2020-09-13 02:15:45 +00:00
|
|
|
let handler: (_ ctx: Context) -> WebApp
|
2019-12-31 16:40:56 +00:00
|
|
|
|
|
|
|
func app(_ environ: [String : Any], startResponse: @escaping ((String, [(String, String)]) -> Void), sendBody: @escaping ((Data) -> Void)) {
|
2020-09-13 02:15:45 +00:00
|
|
|
let ctx = Context(environ: environ)
|
|
|
|
handler(ctx).app(environ, startResponse: startResponse, sendBody: sendBody)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension DelegatingResponse {
|
|
|
|
struct Context {
|
|
|
|
let environ: [String: Any]
|
|
|
|
|
|
|
|
var captures: [String] {
|
|
|
|
environ["ambassador.router_captures"] as? [String] ?? []
|
|
|
|
}
|
2019-12-31 16:40:56 +00:00
|
|
|
}
|
|
|
|
}
|