Complete API handlers refactoring to eliminate type switching and use repository pattern consistently
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -92,13 +93,7 @@ func CORSPreflightHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Check if origin is allowed
|
||||
originAllowed := false
|
||||
for _, allowed := range allowedOrigins {
|
||||
if origin == allowed {
|
||||
originAllowed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
originAllowed := slices.Contains(allowedOrigins, origin)
|
||||
|
||||
if originAllowed {
|
||||
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
|
||||
Reference in New Issue
Block a user