Refactor handler methods to use instance methods for logging and error handling; add utility functions for UUID generation and JSON error responses.

This commit is contained in:
alex
2025-06-22 11:48:33 +03:00
parent 07e1d3ecdd
commit eaff815270
8 changed files with 124 additions and 86 deletions

View File

@@ -1,14 +1,13 @@
package main
import (
"github.com/akyaiy/GoSally-mvp/internal/config"
"github.com/akyaiy/GoSally-mvp/internal/logs"
"crypto/rand"
"encoding/hex"
"log/slog"
"net/http"
"regexp"
"github.com/akyaiy/GoSally-mvp/internal/config"
"github.com/akyaiy/GoSally-mvp/internal/logs"
"github.com/go-chi/chi/v5"
)
@@ -42,13 +41,3 @@ func main() {
http.ListenAndServe(cfg.Address, r)
}
func newUUID() string {
bytes := make([]byte, 16)
_, err := rand.Read(bytes)
if err != nil {
log.Error("Failed to generate UUID", slog.String("error", err.Error()))
return ""
}
return hex.EncodeToString(bytes)
}