def req.put.at

ezmcp@0.1.0.0 · src/openapi.bend:1169

import ezmcp@0.1.0.0/src/openapi.bend as Openapi
import Base
import emerging-ezjson@1.2.0.0/src/value.bend as Value
import emerging-ezhttp@0.21.0.0/src/http.bend as Http
import emerging-ezhttp@0.21.0.0/src/qs.bend as Qs

1169# a parameter's value put in a request: a path parameter filled into the
1170# path (`fill`), a query parameter's pairs added to the query (`query`), a
1171# header parameter a header field of its name in lower case and its text
1172# (`plain`); a cookie parameter, or one of no known location, changes
1173# nothing
1174def req.put.at(
1175  place: Place,
1176  +name: String,
1177  val: Value.Json,
1178  path: String,
1179  pairs: List<&2, Qs.Kv()>,
1180  hs: List<&2, Http.Header>
1181) -> Req:
1182  match place:
1183    case InPath{}:
1184      Req{fill(path, name, val), pairs, hs}
1185    case InQuery{}:
1186      Req{path, List.append(&2, Qs.Kv(), pairs, query(name, val)), hs}
1187    case InHeader{}:
1188      Req{path, pairs, List.append(&2, Http.Header, hs,
1189        [Http.H{String.to_lower(name), plain(val)}])}
1190    case InCookie{}:
1191      Req{path, pairs, hs}
1192    case InNone{}:
1193      Req{path, pairs, hs}

Uses (12)

Used by (1)