From 5aff2563772da9e6f40a9c36ed901400ed2a3fd9 Mon Sep 17 00:00:00 2001 From: allanice001 Date: Tue, 6 Jan 2026 09:59:23 +0000 Subject: [PATCH] fix import issue --- internal/api/routes.go | 1 - internal/handlers/dns.go | 51 ++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/internal/api/routes.go b/internal/api/routes.go index 522886c..575109e 100644 --- a/internal/api/routes.go +++ b/internal/api/routes.go @@ -16,7 +16,6 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" - "github.com/go-chi/httprate" "gorm.io/gorm" diff --git a/internal/handlers/dns.go b/internal/handlers/dns.go index 9fc847a..7d0cb54 100644 --- a/internal/handlers/dns.go +++ b/internal/handlers/dns.go @@ -503,7 +503,6 @@ func ListRecordSets(db *gorm.DB) http.HandlerFunc { } } - // GetRecordSet godoc // // @ID GetRecordSet @@ -517,35 +516,35 @@ func ListRecordSets(db *gorm.DB) http.HandlerFunc { // @Failure 404 {string} string "not found" // @Router /dns/records/{id} [get] func GetRecordSet(db *gorm.DB) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - orgID, ok := httpmiddleware.OrgIDFrom(r.Context()) - if !ok { - utils.WriteError(w, http.StatusForbidden, "org_required", "specify X-Org-ID") - return - } + return func(w http.ResponseWriter, r *http.Request) { + orgID, ok := httpmiddleware.OrgIDFrom(r.Context()) + if !ok { + utils.WriteError(w, http.StatusForbidden, "org_required", "specify X-Org-ID") + return + } - id, err := uuid.Parse(chi.URLParam(r, "id")) - if err != nil { - utils.WriteError(w, http.StatusBadRequest, "bad_id", "invalid UUID") - return - } + id, err := uuid.Parse(chi.URLParam(r, "id")) + if err != nil { + utils.WriteError(w, http.StatusBadRequest, "bad_id", "invalid UUID") + return + } - var row models.RecordSet - if err := db. - Joins("Domain"). - Where(`record_sets.id = ? AND "Domain"."organization_id" = ?`, id, orgID). - First(&row).Error; err != nil { + var row models.RecordSet + if err := db. + Joins("Domain"). + Where(`record_sets.id = ? AND "Domain"."organization_id" = ?`, id, orgID). + First(&row).Error; err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - utils.WriteError(w, http.StatusNotFound, "not_found", "record set not found") - return - } - utils.WriteError(w, http.StatusInternalServerError, "db_error", err.Error()) - return - } + if errors.Is(err, gorm.ErrRecordNotFound) { + utils.WriteError(w, http.StatusNotFound, "not_found", "record set not found") + return + } + utils.WriteError(w, http.StatusInternalServerError, "db_error", err.Error()) + return + } - utils.WriteJSON(w, http.StatusOK, recordOut(&row)) - } + utils.WriteJSON(w, http.StatusOK, recordOut(&row)) + } } // CreateRecordSet godoc