Log errors, requests

This commit is contained in:
wim.de.jager 2021-06-21 16:28:55 +02:00
parent e7af1db33d
commit 7d11cd9d6a

View file

@ -25,6 +25,8 @@ type Error struct {
} }
func writeError(w http.ResponseWriter, statusCode int, err string) { func writeError(w http.ResponseWriter, statusCode int, err string) {
log.Printf(time.Now().Format(time.RFC3339) + "ERROR: " + err)
w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(statusCode) w.WriteHeader(statusCode)
@ -90,6 +92,8 @@ func scanHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
//POST takes the uploaded file(s) and saves it to disk. //POST takes the uploaded file(s) and saves it to disk.
case "POST": case "POST":
log.Printf(time.Now().Format(time.RFC3339) + "Received scan request " + r.RequestURI)
c := clamd.NewClamd(opts["CLAMD_PORT"]) c := clamd.NewClamd(opts["CLAMD_PORT"])
//get the multipart reader for the request. //get the multipart reader for the request.
reader, err := r.MultipartReader() reader, err := r.MultipartReader()