From 1a5664d1d5a706871a6de45c143861e33d43d5c5 Mon Sep 17 00:00:00 2001 From: tommasomoretto Date: Sat, 27 Mar 2021 22:22:15 +0100 Subject: [PATCH] Update post.go Hi, first ok all compliment for your amazing contents. Try to understanding better the refactor you did on productAPI (out-screen between lesson 6 and 7) I find this bug which compromise both the post and put requests. The error is the following: "interface {} is nil, not validator.ValidationErrors" And this is due to the fact that row 20 extract from the context a pointer to Product witch can not be cast to Product. Hope you'll find useful this reporting. Keep going with your video you are an amazing teacher! =) --- product-api/handlers/post.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product-api/handlers/post.go b/product-api/handlers/post.go index bdb2887..4d8dc9e 100644 --- a/product-api/handlers/post.go +++ b/product-api/handlers/post.go @@ -17,8 +17,8 @@ import ( // Create handles POST requests to add new products func (p *Products) Create(rw http.ResponseWriter, r *http.Request) { // fetch the product from the context - prod := r.Context().Value(KeyProduct{}).(data.Product) + prod := r.Context().Value(KeyProduct{}).(*data.Product) p.l.Printf("[DEBUG] Inserting product: %#v\n", prod) - data.AddProduct(prod) + data.AddProduct(*prod) }