Refactor code to use 'any' type and improve context handling
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-18 16:16:27 +11:00
parent 6517a30fa2
commit f2d6b3158b
36 changed files with 197 additions and 175 deletions

View File

@@ -1,7 +1,6 @@
package handler
import (
"context"
"database/sql"
"encoding/json"
"fmt"
@@ -30,6 +29,8 @@ func (h *Handler) VmCreateEvent(w http.ResponseWriter, r *http.Request) {
if h.denyLegacyAPI(w, "/api/event/vm/create") {
return
}
ctx, cancel := withRequestTimeout(r, defaultRequestTimeout)
defer cancel()
var (
unixTimestamp int64
@@ -96,7 +97,7 @@ func (h *Handler) VmCreateEvent(w http.ResponseWriter, r *http.Request) {
h.Logger.Debug("database params", "params", params)
// Insert the new inventory record into the database
result, err := h.Database.Queries().CreateEvent(context.Background(), params)
result, err := h.Database.Queries().CreateEvent(ctx, params)
if err != nil {
h.Logger.Error("unable to perform database insert", "error", err)
writeJSONError(w, http.StatusInternalServerError, fmt.Sprintf("Error: %v", err))
@@ -109,7 +110,7 @@ func (h *Handler) VmCreateEvent(w http.ResponseWriter, r *http.Request) {
}
// prettyPrint comes from https://gist.github.com/sfate/9d45f6c5405dc4c9bf63bf95fe6d1a7c
func prettyPrint(args ...interface{}) {
func prettyPrint(args ...any) {
var caller string
timeNow := time.Now().Format("01-02-2006 15:04:05")