Improvements to enforce middleware, linting, returning 404 properly

This commit is contained in:
Jamie Curnow
2024-09-11 15:03:00 +10:00
parent 833dd23dce
commit 9a2e5c92d5
18 changed files with 110 additions and 104 deletions

View File

@ -1,7 +1,6 @@
package handler
import (
"database/sql"
"encoding/json"
"fmt"
"net/http"
@ -14,6 +13,8 @@ import (
"npm/internal/entity/host"
"npm/internal/jobqueue"
"npm/internal/logger"
"gorm.io/gorm"
)
// GetCertificates will return a list of Certificates
@ -138,7 +139,7 @@ func getCertificateFromRequest(w http.ResponseWriter, r *http.Request) *certific
certificateObject, err := certificate.GetByID(certificateID)
switch err {
case sql.ErrNoRows:
case gorm.ErrRecordNotFound:
h.NotFound(w, r)
case nil:
return &certificateObject