File tree 3 files changed +37
-3
lines changed
3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,43 @@ index: 15
7
7
---
8
8
*)
9
9
10
+ (*** condition: prepare ***)
11
+ #nowarn " 211"
12
+ #r " ../src/FsHttp/bin/Release/net8.0/FsHttp.dll"
13
+ open FsHttp
14
+
15
+
10
16
(**
11
17
## Composability
12
18
13
19
TODO: Use transformHeader to pre-configure URLs
14
20
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 9
9
10
10
(*** condition: prepare ***)
11
11
#nowarn " 211"
12
- #r " ../FsHttp/bin/Release/net8.0/FsHttp.dll"
12
+ #r " ../src/ FsHttp/bin/Release/net8.0/FsHttp.dll"
13
13
open FsHttp
14
14
15
15
Original file line number Diff line number Diff line change 9
9
10
10
(*** condition: prepare ***)
11
11
#nowarn " 211"
12
- #r " ../FsHttp/bin/Release/net8.0/FsHttp.dll"
12
+ #r " ../src/ FsHttp/bin/Release/net8.0/FsHttp.dll"
13
13
open FsHttp
14
14
15
15
You can’t perform that action at this time.
0 commit comments