I'm using gorilla mux to get pattern values. How do I handle an empty variable like so:
Go:
func ProductHandler (w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
a := vars["key"]
if a = "" { //does not seem to register empty string
//do something
} else
//do something
}
var r = mux.NewRouter()
func main() {
r.HandleFunc("/products/{key}", ProductHandler)
http.Handle("/", r)
http.ListenAndServe(":8080", nil)
}
When I type the url www.example.com/products or www.example.com/products/ I get a 404 page not found error. How do i handle an empty variable in ProductHandler?