first commit

This commit is contained in:
Oleh Astappiev 2024-10-16 15:57:59 +02:00
commit 3ca46c9ea2
No known key found for this signature in database
GPG key ID: 37D7AC22589E9632
19 changed files with 958 additions and 0 deletions

24
umami_token.go Normal file
View file

@ -0,0 +1,24 @@
package traefik_umami_feeder
type Auth struct {
Username string `json:"username"`
Password string `json:"password"`
}
type AuthResponse struct {
Token string `json:"token"`
}
func getToken(umamiHost string, umamiUsername string, umamiPassword string) (string, error) {
var result AuthResponse
err := sendRequestAndParse(umamiHost+"/api/auth/login", Auth{
Username: umamiUsername,
Password: umamiPassword,
}, nil, &result)
if err != nil {
return "", err
}
return result.Token, nil
}