Guard a StatusUnprocessableEntity with check for HTMx request
Otherwise, HTMx would just ignore the HTML returned by the server and dispatch an error.
This commit is contained in:
parent
73497eb051
commit
4a9c3748cd
|
@ -137,7 +137,9 @@ func HandleUpdateProduct(w http.ResponseWriter, r *http.Request, params httprout
|
|||
}
|
||||
slug := params[0].Value
|
||||
if !form.Validate() {
|
||||
if !IsHTMxRequest(r) {
|
||||
w.WriteHeader(http.StatusUnprocessableEntity)
|
||||
}
|
||||
mustRenderEditProductForm(w, r, slug, form)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue