Cleaned up documentation and removed stubs and TODOs throughout the application
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -60,9 +59,13 @@ func NewHTTPSource(driver string, cfg config.SourceConfig, accept string) (*HTTP
|
||||
return nil, fmt.Errorf("%s %q: params.user_agent is required", driver, cfg.Name)
|
||||
}
|
||||
|
||||
conditional, err := parseConditionalParam(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
conditional := true
|
||||
if _, exists := cfg.Params["conditional"]; exists {
|
||||
var ok bool
|
||||
conditional, ok = cfg.ParamBool("conditional")
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("source %q: params.conditional must be a boolean", cfg.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return &HTTPSource{
|
||||
@@ -121,27 +124,3 @@ func (s *HTTPSource) FetchJSONIfChanged(ctx context.Context) (json.RawMessage, b
|
||||
}
|
||||
return json.RawMessage(body), true, nil
|
||||
}
|
||||
|
||||
func parseConditionalParam(cfg config.SourceConfig) (bool, error) {
|
||||
raw, ok := cfg.Params["conditional"]
|
||||
if !ok || raw == nil {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
switch v := raw.(type) {
|
||||
case bool:
|
||||
return v, nil
|
||||
case string:
|
||||
s := strings.TrimSpace(v)
|
||||
if s == "" {
|
||||
return false, fmt.Errorf("source %q: params.conditional must be a boolean", cfg.Name)
|
||||
}
|
||||
parsed, err := strconv.ParseBool(s)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("source %q: params.conditional must be a boolean", cfg.Name)
|
||||
}
|
||||
return parsed, nil
|
||||
default:
|
||||
return false, fmt.Errorf("source %q: params.conditional must be a boolean", cfg.Name)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user