1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-31 18:31:01 +00:00

Add per-application API Keys

This commit is contained in:
Frédéric Guillot 2020-03-01 17:38:29 -08:00
parent d1afe13a1c
commit 25cc0d2447
35 changed files with 940 additions and 71 deletions

View file

@ -38,6 +38,7 @@ type request struct {
endpoint string
username string
password string
apiKey string
}
func (r *request) Get(path string) (io.ReadCloser, error) {
@ -75,7 +76,10 @@ func (r *request) execute(method, path string, data interface{}) (io.ReadCloser,
Method: method,
Header: r.buildHeaders(),
}
request.SetBasicAuth(r.username, r.password)
if r.username != "" && r.password != "" {
request.SetBasicAuth(r.username, r.password)
}
if data != nil {
switch data.(type) {
@ -131,6 +135,9 @@ func (r *request) buildHeaders() http.Header {
headers.Add("User-Agent", userAgent)
headers.Add("Content-Type", "application/json")
headers.Add("Accept", "application/json")
if r.apiKey != "" {
headers.Add("X-Auth-Token", r.apiKey)
}
return headers
}