File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,43 @@ index: 15
77---
88*)
99
10+ (* ** condition: prepare ***)
11+ #nowarn " 211"
12+ #r " ../src/FsHttp/bin/Release/net8.0/FsHttp.dll"
13+ open FsHttp
14+
15+
1016(**
1117## Composability
1218
1319TODO: Use transformHeader to pre-configure URLs
1420
15- *)
21+ Currently, see tests/Config.fs (Header Transformer) to get an idea of how to tweak a builder for - e.g - a specific environment.
22+
23+ An example with comments:
24+ *)
25+
26+ open FsHttp
27+ open FsHttp.Operators
28+
29+ let httpForMySpecialEnvironment =
30+ let baseUrl = " http://my-special-environment"
31+ http {
32+ // we would like to have a fixed URL prefix for all requests.
33+ // So we define a new builder that actually transforms the header.
34+ // Since the description of method is a special thing,
35+ // we have to change the URL for any method using a header transformer,
36+ // like so:
37+ config_ transformHeader ( fun ( header : Header ) ->
38+ let address = baseUrl </> header.target.address.Value
39+ { header with target.address = Some address })
40+
41+ // other header values can be just configured as usual:
42+ AuthorizationBearer " **************"
43+ }
44+
45+ let response =
46+ httpForMySpecialEnvironment {
47+ GET " /api/v1/users"
48+ }
49+ |> Request.sendAsync
Original file line number Diff line number Diff line change 99
1010(* ** condition: prepare ***)
1111#nowarn " 211"
12- #r " ../FsHttp/bin/Release/net8.0/FsHttp.dll"
12+ #r " ../src/ FsHttp/bin/Release/net8.0/FsHttp.dll"
1313open FsHttp
1414
1515
Original file line number Diff line number Diff line change 99
1010(* ** condition: prepare ***)
1111#nowarn " 211"
12- #r " ../FsHttp/bin/Release/net8.0/FsHttp.dll"
12+ #r " ../src/ FsHttp/bin/Release/net8.0/FsHttp.dll"
1313open FsHttp
1414
1515
You can’t perform that action at this time.
0 commit comments