-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry_options.go
92 lines (76 loc) · 2.57 KB
/
registry_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package streamnx
import (
"net/http"
"github.com/GeorgeGorbanev/streamnx/internal/apple"
"github.com/GeorgeGorbanev/streamnx/internal/spotify"
"github.com/GeorgeGorbanev/streamnx/internal/translator"
"github.com/GeorgeGorbanev/streamnx/internal/yandex"
"github.com/GeorgeGorbanev/streamnx/internal/youtube"
)
type RegistryOption func(registry *Registry)
type clientOptions struct {
apple []apple.ClientOption
spotify []spotify.ClientOption
yandex []yandex.ClientOption
youtube []youtube.ClientOption
}
func WithProviderAdapter(provider *Provider, adapter Adapter) RegistryOption {
return func(r *Registry) {
r.adapters[provider.сode] = adapter
}
}
func WithTranslator(translator translator.Translator) RegistryOption {
return func(r *Registry) {
r.translator = translator
}
}
func WithAppleWebPlayerURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.apple = append(r.clientOptions.apple, apple.WithWebPlayerURL(url))
}
}
func WithAppleAPIURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.apple = append(r.clientOptions.apple, apple.WithAPIURL(url))
}
}
func WithSpotifyAuthURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.spotify = append(r.clientOptions.spotify, spotify.WithAuthURL(url))
}
}
func WithSpotifyAPIURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.spotify = append(r.clientOptions.spotify, spotify.WithAPIURL(url))
}
}
func WithYandexAPIURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.yandex = append(r.clientOptions.yandex, yandex.WithAPIURL(url))
}
}
func WithYoutubeAPIURL(url string) RegistryOption {
return func(r *Registry) {
r.clientOptions.youtube = append(r.clientOptions.youtube, youtube.WithAPIURL(url))
}
}
func WithAppleHTTPTransport(transport *http.Transport) RegistryOption {
return func(r *Registry) {
r.clientOptions.apple = append(r.clientOptions.apple, apple.WithHTTPTransport(transport))
}
}
func WithSpotifyHTTPTransport(transport *http.Transport) RegistryOption {
return func(r *Registry) {
r.clientOptions.spotify = append(r.clientOptions.spotify, spotify.WithHTTPTransport(transport))
}
}
func WithYandexHTTPTransport(transport *http.Transport) RegistryOption {
return func(r *Registry) {
r.clientOptions.yandex = append(r.clientOptions.yandex, yandex.WithHTTPTransport(transport))
}
}
func WithYoutubeHTTPTransport(transport *http.Transport) RegistryOption {
return func(r *Registry) {
r.clientOptions.youtube = append(r.clientOptions.youtube, youtube.WithHTTPTransport(transport))
}
}