A self-hosted dashboard that puts all your feeds in one place
Go aggregatordashboarddockerfeed-readergohomelabhomepagemonitoringredditrssrss-readerself-hostedstartpageyoutube
Add basic auth support to custom API
Svilen Markov736e06018008
diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.goindex c70d5c2..2d32495 100644--- a/internal/glance/widget-custom-api.go+++ b/internal/glance/widget-custom-api.go@@ -33,8 +33,12 @@ type CustomAPIRequest struct {BodyType string `yaml:"body-type"`Body any `yaml:"body"`SkipJSONValidation bool `yaml:"skip-json-validation"`- bodyReader io.ReadSeeker `yaml:"-"`- httpRequest *http.Request `yaml:"-"`+ BasicAuth struct {+ Username string `yaml:"username"`+ Password string `yaml:"password"`+ } `yaml:"basic-auth"`+ bodyReader io.ReadSeeker `yaml:"-"`+ httpRequest *http.Request `yaml:"-"`}type customAPIWidget struct {@@ -187,6 +191,10 @@ func (req *CustomAPIRequest) initialize() error {httpReq.Header.Add(key, value)}+ if req.BasicAuth.Username != "" || req.BasicAuth.Password != "" {+ httpReq.SetBasicAuth(req.BasicAuth.Username, req.BasicAuth.Password)+ }+req.httpRequest = httpReqreturn nil@@ -673,6 +681,11 @@ var customAPITemplateFuncs = func() template.FuncMap {return req},+ "withBasicAuth": func(username, password string, req *CustomAPIRequest) *CustomAPIRequest {+ req.BasicAuth.Username = username+ req.BasicAuth.Password = password+ return req+ },"getResponse": func(req *CustomAPIRequest) *customAPIResponseData {err := req.initialize()if err != nil {