mirror of
https://github.com/GlueOps/autoglue.git
synced 2026-02-13 04:40:05 +01:00
fix import issue
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
"github.com/go-chi/cors"
|
"github.com/go-chi/cors"
|
||||||
"github.com/go-chi/httprate"
|
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
|
|||||||
@@ -503,7 +503,6 @@ func ListRecordSets(db *gorm.DB) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetRecordSet godoc
|
// GetRecordSet godoc
|
||||||
//
|
//
|
||||||
// @ID GetRecordSet
|
// @ID GetRecordSet
|
||||||
@@ -517,35 +516,35 @@ func ListRecordSets(db *gorm.DB) http.HandlerFunc {
|
|||||||
// @Failure 404 {string} string "not found"
|
// @Failure 404 {string} string "not found"
|
||||||
// @Router /dns/records/{id} [get]
|
// @Router /dns/records/{id} [get]
|
||||||
func GetRecordSet(db *gorm.DB) http.HandlerFunc {
|
func GetRecordSet(db *gorm.DB) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
orgID, ok := httpmiddleware.OrgIDFrom(r.Context())
|
||||||
if !ok {
|
if !ok {
|
||||||
utils.WriteError(w, http.StatusForbidden, "org_required", "specify X-Org-ID")
|
utils.WriteError(w, http.StatusForbidden, "org_required", "specify X-Org-ID")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := uuid.Parse(chi.URLParam(r, "id"))
|
id, err := uuid.Parse(chi.URLParam(r, "id"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteError(w, http.StatusBadRequest, "bad_id", "invalid UUID")
|
utils.WriteError(w, http.StatusBadRequest, "bad_id", "invalid UUID")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var row models.RecordSet
|
var row models.RecordSet
|
||||||
if err := db.
|
if err := db.
|
||||||
Joins("Domain").
|
Joins("Domain").
|
||||||
Where(`record_sets.id = ? AND "Domain"."organization_id" = ?`, id, orgID).
|
Where(`record_sets.id = ? AND "Domain"."organization_id" = ?`, id, orgID).
|
||||||
First(&row).Error; err != nil {
|
First(&row).Error; err != nil {
|
||||||
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
utils.WriteError(w, http.StatusNotFound, "not_found", "record set not found")
|
utils.WriteError(w, http.StatusNotFound, "not_found", "record set not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.WriteError(w, http.StatusInternalServerError, "db_error", err.Error())
|
utils.WriteError(w, http.StatusInternalServerError, "db_error", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.WriteJSON(w, http.StatusOK, recordOut(&row))
|
utils.WriteJSON(w, http.StatusOK, recordOut(&row))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRecordSet godoc
|
// CreateRecordSet godoc
|
||||||
|
|||||||
Reference in New Issue
Block a user