fetch issues the API call, upgrades to Bearer auth when a key is available.
(ctx context.Context, domain string, session *subscraping.Session)
| 84 | |
| 85 | // fetch issues the API call, upgrades to Bearer auth when a key is available. |
| 86 | func (s *Source) fetch(ctx context.Context, domain string, session *subscraping.Session) (*http.Response, error) { |
| 87 | endpoint := "https://api.sub.md/v1/search?apex=" + url.QueryEscape(domain) |
| 88 | |
| 89 | if len(s.apiKeys) > 0 { |
| 90 | return session.Get(ctx, endpoint, "", map[string]string{ |
| 91 | "Authorization": "Bearer " + subscraping.PickRandom(s.apiKeys, s.Name()), |
| 92 | }) |
| 93 | } |
| 94 | return session.SimpleGet(ctx, endpoint) |
| 95 | } |
| 96 | |
| 97 | func (s *Source) Name() string { return "submd" } |
| 98 | func (s *Source) IsDefault() bool { return true } |
no test coverage detected