Initial commit.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var errRSSValidate = errors.New("validate RSS configuration")
|
||||
|
||||
// RSS is an RSS parser configuration.
|
||||
type RSS struct {
|
||||
HTTPClient *HTTPClient `json:"http_client"`
|
||||
Feeds []*Feed `json:"feeds"`
|
||||
}
|
||||
|
||||
// Validate validates RSS parser configuration.
|
||||
func (r *RSS) Validate() error {
|
||||
for idx, feed := range r.Feeds {
|
||||
if err := feed.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: feed %d: %w", errRSSValidate, idx, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.HTTPClient.Validate(); err != nil {
|
||||
return fmt.Errorf("%w: %w", errRSSValidate, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user