Disqus avatars - straightforward approach #1513
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The most straightforward fix for avatars import ( #990 ) mostly to start discussion of possible approaches.
I don't like current fix but I don't see another way without code duplication or refactoring of auth package.
The best way that I see it's split
backend/vendor/github.com/go-pkgz/auth/avatar/avatar.go
file to 2 structs,Proxy
andAvatarSaver
.First of all, because they have different responsibility,
Proxy
works with paths, andAvatarSaver
should declare rules how to save avatar. Even if we will look use cases, proxy and AvatarSaver parts uses in different scenarios.AvatarSaver can use Proxy to save avatar, but it shouldn't be same struct.
Also will needed to provide possibility to pass
Proxy
andAvatarSaver
instances as parameters of auth package. If talk aboutAvatarSaver
maybe we need provide possibility to pass it in runtime (as a param to save method).This approach will provide possibility to declare different save mechanism for different providers.
Each third party api can have different ratelimits, etc, and maybe even different protocols, not http. With this approach we will be able to configure it specifically for each API.
Will be glad to hear other ideas.