Handle encoding error for generating url api

This commit is contained in:
Tri Vo 2023-08-20 19:23:57 +07:00 committed by Lena Fuhrimann
parent 4858c7493b
commit 05728d1209

View file

@ -38,6 +38,10 @@ func HandleGenerateUrl(s3 S3) http.HandlerFunc {
encoder := json.NewEncoder(w)
encoder.SetEscapeHTML(false)
encoder.Encode(map[string]string{"url": url.String()})
err = encoder.Encode(map[string]string{"url": url.String()})
if err != nil {
handleHTTPError(w, fmt.Errorf("error encoding JSON: %w", err))
return
}
}
}