Refactor code to use 'any' type and improve context handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user