def origin.route
bend-kit-http@0.38.2.0 · http.bend:3813
import bend-kit-http@0.38.2.0/http.bend as Http
import Base
import bend-kit-url@0.4.1.0/url.bend as Url
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
3813
3814def origin.route(+method: String, headers: Map<&2, List<&2, String>>,
3815 body: Bytes.Bytes, +hf: String, +scheme: String, +host: String, +port: U32,
3816 +target: String, +cert: Maybe<&2, Cert>, +ca: String, proxy: Proxy) ->
3817 String & Send & Route:
3818 match proxy:
3819 case ProxyDirect{}:
3820 (pool.key.trust(pool.key(scheme, host, port), cert, ca),
3821 Send{method, target, hf, headers, body},
3822 RouteDirect{String.eq(scheme, "https"), host, port, cert, ca})
3823 case ProxyVia{+proxy_host, +proxy_port, +authorization}:
3824 +secure = String.eq(scheme, "https")
3825 (pool.key.trust(pool.key(scheme, host, port)
3826 ++ "|proxy:" ++ proxy_host ++ ":" ++ U32.show(proxy_port)
3827 ++ "|auth:" ++ authorization, cert, ca),
3828 proxy.request(secure, scheme, method, target, hf, headers, body, authorization),
3829 RouteProxy{secure, proxy_host, proxy_port, host,
3830 Url.host_field.wrap(host, Url.has(host, 58)) ++ ":" ++ U32.show(port),
3831 authorization, cert, ca})