src/wirespec.bend
emerging-ezhttp@0.9.0.0 · 18 lines · 0 definitions
1# ezhttp/src/wirespec: the text the wire effect reads, pure. Kept apart from
2# wire.bend (the effect) so the proof gate can import it.
3#
4# Spec: scheme, host, port each on their own line; everything after the third
5# newline is the request verbatim.
6import Base
7
8# the word the effect reads for a scheme that wants TLS
9def wire.scheme(secure: Bool) -> String:
10 match secure:
11 case True{}:
12 "tls"
13 case False{}:
14 "tcp"
15
16# the spec the effect reads
17def wire.spec(secure: Bool, host: String, port: U32, req: String) -> String:
18 wire.scheme(secure) ++ "\n" ++ host ++ "\n" ++ U32.show(port) ++ "\n" ++ req