Comments (10)
from tesla.
Sure, opts could be used, but I think it's would be cleaner to not mix different entities under same key.
For me :opts
is write-only for user and read-only for Tesla when :private
will be opposite.
What do I mean by this?
When you do Tesla.get(url, opts: [something: true])
you probably don't care about what's saved under :opts
key in response, because you know what you have passed in function call. On the other hand Tesla shouldn't use data from :private
when making request, because this field would allow to store inconsistent data(specific to one adapter/middleware), which from end user perspective may be useful.
#some pseudocode to make this 100% clear
important_in_request = [follow_redirect: true]
ignored_by_tesla = [random_key: :value]
%Tesla.Env{
opts: _user_probably_dont_care,
private: additional_data_that_user_may_be_interested_in
} = Tesla.get(url, opts: important_in_request, private: ignored_by_tesla)
from tesla.
I agree mixing opts with private might not be a good idea.
One question remains - what should be the desired adapter's behaviour and rules for using private properties? (Assuming client code does not modify adapters)
In case of "follow redirects" I think this should be a tesla middleware like this
from tesla.
My first idea for private properties can be described as "allow to store anything useful, don't merge to master anything that tries to read from it". I'll think about it more later, but unfortunately I'm little busy at the moment.
about FollowRedirects middleware
I like this, it will allow me to remove custom implementation from my library
one note: httpc default for autoredirect is true, you should probably disable it inside this middleware
btw I made middleware for data compression
https://github.com/amatalai/link_preview/blob/1.0.0/lib/compression_middleware.ex
It's work in progress now, but I think that I'll have time to finish it in next few days (I'll make separate issue tomorrow to discuss details)
from tesla.
@amatalai sooooo, what are we doing with this? ;)
from tesla.
I wish I could create PR with some proposal to push work on this forward, but lately I don't have time to do that.
from tesla.
I need to revisit this idea. With ability to add middleware before adapter it should be easy to save raw headers etc with simple middleware and without any breaking changes.
from tesla.
As mentioned in #104 there was always a possibility to add something right around adapter :)
from tesla.
Please see possible solution in #37
from tesla.
Yeah, this wouldn't be useful at the moment
from tesla.
Related Issues (20)
- Cannot get Tesla.Mock to work HOT 7
- Retry middleware: Is there a way to know which request is being retried? HOT 1
- Replace Application.get_env to Application.compile_env in module body
- Mint adapter is passing a 3 element error tuple to Tesla.request HOT 1
- Cryptic {:error, :closed} return from a POST HOT 3
- Compression middleware doesn't update `content-*` headers after decompression
- Fuck you HOT 2
- G
- Document the need for telemetry in the mix file HOT 3
- Mint proxy credentials HOT 1
- Issues Working with QuotaGuard QGTunnel HOT 3
- [Proposal] Lower the usage of macros HOT 2
- Setting retry delay on runtime. HOT 1
- Telemetry metadata doesn't have data about response in case of error
- Dialyzer failing on Tesla (master) HOT 3
- Tesla Response Stream is not compatible with Tesla Multipart upload
- Jason.Encoder protocol must always be explicitly implemented HOT 1
- Be more explict on `:no_scheme` error reason HOT 1
- When setting the adapter on runtime, mocking does not work
- Logger debug: true does nothing at runtime HOT 2
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 tesla.