setCurrent

This commit is contained in:
Mitsu
2025-07-09 20:00:11 +02:00
parent 5281f73148
commit 684cd08c1c
4 changed files with 60 additions and 5 deletions
+13
View File
@@ -2,12 +2,25 @@ package utils
import (
"encoding/json"
"errors"
"net/http"
"strconv"
"time"
"github.com/siestaw/laterna/server/cmd/internal/models"
)
func IDtoInt(id string) (int, error) {
idInt, err := strconv.Atoi(id)
if err != nil {
return 0, errors.New("invalid ID format")
}
if idInt < 0 {
return 0, errors.New("ID must not be negative")
}
return idInt, nil
}
func HTTPErrorHandling(w http.ResponseWriter, r *http.Request, status int, message string) {
timestamp := time.Now().Format("2006-01-02_15-04-05")
errResp := models.HTTPError{