def wire.after.resolve

emerging-ezhttp@0.21.0.0 · src/wire.bend:224

import emerging-ezhttp@0.21.0.0/src/wire.bend as Wire
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
import emerging-ezhttp@0.21.0.0/src/wirespec.bend as Spec

224# after the resolve: connect, or the resolve's failure (no address at all is
225# ENOENT, as bend-kit-dns reports a name with none)
226def wire.after.resolve(+secure: Bool, +host: String, +port: U32, +ms: U32,
227  +method: String, payload: Bytes.Bytes,
228  r: Result<&1, &1, U32 & String, List<&2, String>>) -> IO(Answer):
229  match r:
230    case Fail{(n, why)}:
231      IO.pure(Answer,
232        Failed{Spec.wire.fail(Spec.Resolve{}, host, port, ms, n, why)})
233    case Done{[]}:
234      IO.pure(Answer,
235        Failed{Spec.wire.fail(Spec.Resolve{}, host, port, ms, 2, "")})
236    case Done{ip <> t}:
237      IO.bind(Result<&1, &1, U32 & String, Socket>, Answer,
238        wire.dial(t, ip, port, ms),
239        c => wire.after.connect(secure, host, port, ms, method, payload, c))

Uses (17)

Used by (1)