Git Product home page Git Product logo

Comments (6)

SchlenkR avatar SchlenkR commented on May 24, 2024

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.

queil avatar queil commented on May 24, 2024

@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.

SchlenkR avatar SchlenkR commented on May 24, 2024

That sounds to me pretty close to the example I posted above, isn’t it?

from fshttp.

queil avatar queil commented on May 24, 2024

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.

SchlenkR avatar SchlenkR commented on May 24, 2024

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.

queil avatar queil commented on May 24, 2024

@RonaldSchlenker That's fine. I think I can solve it easily with DelegatingHandler.

from fshttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.