No changes made

This commit is contained in:
2025-04-16 12:47:04 -04:00
commit 1ed3b0c2d4
98 changed files with 8857 additions and 0 deletions

45
backend/handlers/uuid.go Normal file
View File

@@ -0,0 +1,45 @@
package handlers
import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"
)
func ParseUuidOrEmpty(s string) *pgtype.UUID {
ParsedUuid, err := uuid.Parse(s)
if err != nil {
return &pgtype.UUID{
Valid: false,
}
}
return &pgtype.UUID{
Bytes: ParsedUuid,
Valid: true,
}
}
func ParseUuid(s string) (*pgtype.UUID, error) {
uid, err := uuid.Parse(s)
if err != nil {
return nil, err
}
return &pgtype.UUID{
Bytes: uid,
Valid: true,
}, nil
}
func ParseUuidOrBadRequest(c echo.Context, s string) *pgtype.UUID {
uid, err := ParseUuid(s)
if err != nil {
_ = BadRequest(c, "Invalid UUID.")
return nil
}
return uid
}