Validation logs not showing up using cURL
kwiat1990 opened this issue · 0 comments
kwiat1990 commented
Hi, and thank you for the great series!
I'm currently after Episode 6, where a JSON validator was introduced to handle validation in PUT and POST requests. It does work for me as in your video but with a one difference. If I use cURL I don't see validation errors while making those requests. It returns only correct HTTP status (Bad Request) but logs only something like parse error: Invalid numeric literal at line 1, column 6
. In this case I can only see a printed log message inside the terminal, where the server runs. Oddly enough it does work if using Postman or any other HTTP Client, which display that error in the response from the server.
// products.go
err = prod.Validate()
if err != nil {
// get logged in terminal
t.l.Printf("[ERROR] validating product: %s\n", err)
// get returned in response while using Postman but not in cUrl
http.Error(
rw,
fmt.Sprintf("Error validating product: %s", err),
http.StatusBadRequest)
return
}
It was enough jq
to delete from the request.