Lint fixes and testing workflow actions
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"git.warky.dev/wdevs/whatshooked/pkg/config"
|
||||
"git.warky.dev/wdevs/whatshooked/pkg/hooks"
|
||||
"git.warky.dev/wdevs/whatshooked/pkg/logging"
|
||||
"git.warky.dev/wdevs/whatshooked/pkg/whatsapp"
|
||||
)
|
||||
|
||||
@@ -54,3 +56,17 @@ func (h *Handlers) WithAuthConfig(cfg *AuthConfig) *Handlers {
|
||||
h.authConfig = cfg
|
||||
return h
|
||||
}
|
||||
|
||||
// writeJSON is a helper that writes JSON response and logs errors
|
||||
func writeJSON(w http.ResponseWriter, v interface{}) {
|
||||
if err := json.NewEncoder(w).Encode(v); err != nil {
|
||||
logging.Error("Failed to encode JSON response", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
// writeBytes is a helper that writes bytes and logs errors
|
||||
func writeBytes(w http.ResponseWriter, data []byte) {
|
||||
if _, err := w.Write(data); err != nil {
|
||||
logging.Error("Failed to write response", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user