initialize paraclub-ai-mailer project with core components and configuration

This commit is contained in:
2025-03-01 00:32:27 +01:00
commit 34c35c395f
11 changed files with 848 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package fetcher
import (
"io"
"net/http"
"time"
)
type Fetcher struct {
client *http.Client
}
func New() *Fetcher {
return &Fetcher{
client: &http.Client{
Timeout: 30 * time.Second,
},
}
}
func (f *Fetcher) FetchContent(url string) (string, error) {
resp, err := f.client.Get(url)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
return string(body), nil
}
func (f *Fetcher) FetchAllURLs(urls []string) (map[string]string, error) {
results := make(map[string]string)
for _, url := range urls {
content, err := f.FetchContent(url)
if err != nil {
return nil, err
}
results[url] = content
}
return results, nil
}