feat: refactoring

This commit is contained in:
2025-05-17 20:32:53 +02:00
parent 956037fc03
commit fab01674d5
7 changed files with 364 additions and 330 deletions

16
pkg/http/handle_error.go Normal file
View File

@@ -0,0 +1,16 @@
package http
import (
"encoding/json"
"net/http"
)
type ErrorResponse struct {
Error string `json:"error"`
}
func WriteError(w http.ResponseWriter, message string, code int) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(code)
json.NewEncoder(w).Encode(ErrorResponse{Error: message})
}