Skip to content

Commit

Permalink
docu
Browse files Browse the repository at this point in the history
  • Loading branch information
SchlenkR committed Jan 2, 2024
1 parent 3f855d1 commit 84a94c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
36 changes: 35 additions & 1 deletion docs/Composability.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,43 @@ index: 15
---
*)

(*** condition: prepare ***)
#nowarn "211"
#r "../src/FsHttp/bin/Release/net8.0/FsHttp.dll"
open FsHttp


(**
## Composability
TODO: Use transformHeader to pre-configure URLs
*)
Currently, see tests/Config.fs (Header Transformer) to get an idea of how to tweak a builder for - e.g - a specific environment.
An example with comments:
*)

open FsHttp
open FsHttp.Operators

let httpForMySpecialEnvironment =
let baseUrl = "http://my-special-environment"
http {
// we would like to have a fixed URL prefix for all requests.
// So we define a new builder that actually transforms the header.
// Since the description of method is a special thing,
// we have to change the URL for any method using a header transformer,
// like so:
config_transformHeader (fun (header: Header) ->
let address = baseUrl </> header.target.address.Value
{ header with target.address = Some address })

// other header values can be just configured as usual:
AuthorizationBearer "**************"
}

let response =
httpForMySpecialEnvironment {
GET "/api/v1/users"
}
|> Request.sendAsync
2 changes: 1 addition & 1 deletion docs/FSI.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ index: 9

(*** condition: prepare ***)
#nowarn "211"
#r "../FsHttp/bin/Release/net8.0/FsHttp.dll"
#r "../src/FsHttp/bin/Release/net8.0/FsHttp.dll"
open FsHttp


Expand Down
2 changes: 1 addition & 1 deletion docs/Overview.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ index: 2

(*** condition: prepare ***)
#nowarn "211"
#r "../FsHttp/bin/Release/net8.0/FsHttp.dll"
#r "../src/FsHttp/bin/Release/net8.0/FsHttp.dll"
open FsHttp


Expand Down

0 comments on commit 84a94c7

Please sign in to comment.