GithubHelp home page GithubHelp logo

Comments (6)

teamon avatar teamon commented on August 15, 2024 3

Disclaimer: I'm the author of tesla

BaseUrlFromConfig middleware was removed because it is not needed, you can achieve the same thing using:

plug Tesla.Middleware.BaseUrl, fetch_base_url_however_you_like()
# or
plug Tesla.Middleware.BaseUrl, Application.get_env(:google, :base_uri)

Middleware arguments are evaluated at runtime so everything will work just fine.

from elixir-google-api.

jeffdeville avatar jeffdeville commented on August 15, 2024 1

**Ok, NM. Just discovered swagger codegen, and it looks like this wasn't your decision to make. **

FWIW, Tesla, like Faraday that it's based on, introduced a ton of complexity for what looked like very little value. I can see where the idea came from, since just about all web frameworks do the same thing, but for an API client, there's really just 3 concerns. Where it's going, how it's secured, and how to format the data you need to send. A pipeline model is simply overkill.

Obviously I shouldn't really care what the underlying tech is here, and perhaps with this swagger code generator you have there's something it adds. But if not, I'd personally consider dropping it in favor of using the HTTPoison.Base macro instead. Short of that, it looks like tesla needs to be flexible enough to take it's various plug parameters as function definitions, and invoke them at runtime to allow things to be configurable.

from elixir-google-api.

florinpatrascu avatar florinpatrascu commented on August 15, 2024 1

@teamon - I did that in my fork of the mustache templates, and it works very well, even closer to the initial intent of the author?! That of using a package specific env var. In my fork:

    Tesla.build_client([
      {Tesla.Middleware.BaseUrl, env_base_url()},
      {Tesla.Middleware.Headers, [{"Authorization", "Bearer #{token}"}]}
    ])

where the env_base_url is as simple as this:

  defp env_base_url() do
    Application.get_env(:{{#underscored}}{{packageName}}{{/underscored}}, :url, "{{{basePath}}}")
  end

@chingor13 - please observe the use of packageName rather than the appName, as the latter will result in something like: :google_cloud_pub/sub_api, an invalid Elixir Atom, of course.

from elixir-google-api.

chingor13 avatar chingor13 commented on August 15, 2024 1

We just released new versions of the client libraries which includes the fix from #81

from elixir-google-api.

chingor13 avatar chingor13 commented on August 15, 2024

Thanks, for the report.

It looks like BaseUrlFromConfig is being removed from Tesla so we'll need to find a different approach to allow configuring the base url.

from elixir-google-api.

chingor13 avatar chingor13 commented on August 15, 2024

So yes, these libraries are all generated via Swagger Codegen. We do maintain our own templates here, so it's possible to swap out Tesla. Originally we picked Tesla because of multipart http posts and the ease of building requests.

We do have a goal to try and create a shared core library which could encapsulate the transport and try and simplify the generated code (and allow better configuration). We could either switch to HTTPoison or provide an equivalent BaseUrlFromConfig implementation.

Alternatively, we can look to simply swap out the middleware if we're ok locking the 0.x (the middleware is being removed in 1.0), but it could conflict in the future.

from elixir-google-api.

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.