Skip to content

Commit

Permalink
Fix call
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibling committed Feb 4, 2024
1 parent c145340 commit 08ec247
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func ListemSmtps(tlss *smtp.Server) {
func ListenHealthcheck(cfg *Config) {
updateToken := os.Getenv("X_UPDATE_TOKEN")

http.HandleFunc("/accounts.json", func(w http.ResponseWriter, r *http.Request) {
handleAccountsFunc := func(w http.ResponseWriter, r *http.Request) {
if updateToken == "" {
w.WriteHeader(500)
w.Write([]byte("X_UPDATE_TOKEN not set"))
Expand Down Expand Up @@ -250,9 +250,14 @@ func ListenHealthcheck(cfg *Config) {
cfg.Credentials = updatedAccounts
fmt.Println("Updated accounts: ")
fmt.Println(cfg.Credentials)
})
}

http.HandleFunc("/accounts.json", handleAccountsFunc)

http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/accounts.json" && r.Method == "POST" {
handleAccountsFunc(w, r)
}
w.WriteHeader(200)
w.Write([]byte("OK"))
})) // nolint:errcheck
Expand Down

0 comments on commit 08ec247

Please sign in to comment.