diff options
Diffstat (limited to 'internal/client')
| -rw-r--r-- | internal/client/crawl.go | 8 | ||||
| -rw-r--r-- | internal/client/github.go | 17 |
2 files changed, 21 insertions, 4 deletions
diff --git a/internal/client/crawl.go b/internal/client/crawl.go index f33fbcd..330bb88 100644 --- a/internal/client/crawl.go +++ b/internal/client/crawl.go @@ -8,10 +8,16 @@ import ( "net/url" ) -func (c *Client) CrawlDomain(domain string, callback func(line string) error) error { +func (c *Client) CrawlDomain(domain string, subdomains bool, callback func(line string) error) error { path := fmt.Sprintf("/crawl/%s", url.PathEscape(domain)) fullURL := c.config.BaseURL + path + if subdomains { + params := url.Values{} + params.Set("subdomains", "true") + fullURL += "?" + params.Encode() + } + req, err := http.NewRequest(http.MethodGet, fullURL, nil) if err != nil { return fmt.Errorf("failed to create request: %w", err) diff --git a/internal/client/github.go b/internal/client/github.go index f8b7097..35e8b2c 100644 --- a/internal/client/github.go +++ b/internal/client/github.go @@ -58,19 +58,30 @@ func (c *Client) SearchGitHubLeads(query string, callback func(result json.RawMe return nil } -func (c *Client) SearchGitHubLeadsWithParams(query, sort, exclude string, callback func(result json.RawMessage) error) error { +func (c *Client) SearchGitHubLeadsWithParams(query, sort, exclude, format, bio string, callback func(result json.RawMessage) error) error { path := "/github/leads" params := url.Values{} - params.Set("q", query) + if query != "" { + params.Set("q", query) + } if sort != "" { params.Set("sort", sort) } if exclude != "" { params.Set("exclude", exclude) } + if format != "" { + params.Set("format", format) + } + if bio != "" { + params.Set("bio", bio) + } - fullURL := c.config.BaseURL + path + "?" + params.Encode() + fullURL := c.config.BaseURL + path + if len(params) > 0 { + fullURL += "?" + params.Encode() + } req, err := http.NewRequest(http.MethodGet, fullURL, nil) if err != nil { |
