Skip to content

Commit 84a94c7

Browse files
committed
docu
1 parent 3f855d1 commit 84a94c7

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

docs/Composability.fsx

+35-1
Original file line numberDiff line numberDiff 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
1319
TODO: 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

docs/FSI.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ index: 9
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"
1313
open FsHttp
1414

1515

docs/Overview.fsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ index: 2
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"
1313
open FsHttp
1414

1515

0 commit comments

Comments
 (0)