Comments (6)
Hi @queil , thanks for the issue.
What's the purpose of having an async message transformer? I could think of such an example:
let request = task {
let! theContent = File.ReadAllTextAsync("c:/temp/content.txt")
return! http {
GET "https://www.wikipedia.de"
config_transformHttpRequestMessage (fun msg ->
do msg.Content <- new StringContent(theContent)
msg
)
}
}
What we can see in the example is: As soon as an async-fetched value is used in request definition (no matter if it's a header, content, transformer, config value, etc.), the whole request definition has to be lifted to async. It does not matter whether the asynchronous call occurs before the request definition (like in this example) or within - the effect is always the same.
This would require the internal implementation to be based on async - and I mean all of the internals. This is something that I think is not practicable, since the definition of a request is just data, and if a value is based on e.g. IO, it's always possible wrapping the request definition in a task (and being honest about that fact that it's async).
from fshttp.
@RonaldSchlenker Thanks for your response. I have a use case in which I asynchronously read request's content and store it (also asynchronously) in a data store before sending. Then such a logging function I can apply in multiple requests (think of a declarative HttpClientHandler). Does this make sense?
from fshttp.
That sounds to me pretty close to the example I posted above, isn’t it?
from fshttp.
The effect is technically the same in the sense, that yes, in both cases the code runs before the request. But this doesn't feel very elegant. I.e. I hoped to use it like a pipeline or middleware but I understand, as you said, that rewriting the whole internals to async just to support this is not very practical.
from fshttp.
If you want, you could provide a more complete example of how you think it could look like. Maybe there’s something in your idea which I don’t see.
from fshttp.
@RonaldSchlenker That's fine. I think I can solve it easily with DelegatingHandler
.
from fshttp.
Related Issues (20)
- .NET 7 not working: "The format of value '' is invalid" HOT 2
- Remove: printfn "Download response received - starting download..." HOT 2
- Encoding issue in FSI response content printing
- Not escaped query value part HOT 2
- Turning off debug logs in FSI HOT 3
- Update Readme
- Support Repeating Query Parameters
- ContentTypeForPart custom operations should come after part definition
- Make `logfn` optional HOT 8
- Remove ./docs generated output and deploy directy to GH pages via workflow
- Update FS Docs to modernized theme
- Rework build.fsx
- Use implicit yields instead of CustOps
- FsHttp Has an Implicit Dependency on Fsharp.Core 8.0+ from version 12.0.0 on HOT 3
- config_baseUrl shortcut
- FSharp.Core dependency confusion HOT 4
- JSON Docu
- Guard semantic versioning for major changes using binary compat checks in .fsproj HOT 5
- How to strip secrets from requests and responses?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fshttp.