add middleware for perflite requests and delete cors from user and auth
handlers
This commit is contained in:
@@ -43,14 +43,6 @@ func (h *UserHandler) Routes() chi.Router {
|
||||
return r
|
||||
}
|
||||
|
||||
// Обработчик для OPTIONS запросов
|
||||
func (h *UserHandler) handleOptions(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Methods", "PUT, GET, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
w.Header().Set("Access-Control-Max-Age", "300")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Email string `json:"email"`
|
||||
@@ -66,9 +58,6 @@ type UserResponse struct {
|
||||
}
|
||||
|
||||
func (h *UserHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
|
||||
// Устанавливаем CORS заголовки
|
||||
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
|
||||
h.logger.Info("handling get profile request",
|
||||
zap.String("method", r.Method),
|
||||
@@ -101,11 +90,6 @@ type UpdateProfileRequest struct {
|
||||
}
|
||||
|
||||
func (h *UserHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
// Устанавливаем CORS заголовки
|
||||
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
|
||||
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "PUT, OPTIONS")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
|
||||
h.logger.Info("handling update profile request",
|
||||
zap.String("method", r.Method),
|
||||
|
||||
Reference in New Issue
Block a user