use formdata instead of url encoded valus
This commit is contained in:
@@ -49,10 +49,6 @@ func GetMessage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DeleteMessage(w http.ResponseWriter, r *http.Request) {
|
func DeleteMessage(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodDelete {
|
|
||||||
http.Error(w, "Invalid request method", http.StatusMethodNotAllowed)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
message, ok := r.Context().Value(messageKey{}).(*Message)
|
message, ok := r.Context().Value(messageKey{}).(*Message)
|
||||||
if !ok || message == nil {
|
if !ok || message == nil {
|
||||||
render.Render(w, r, ErrNotFound)
|
render.Render(w, r, ErrNotFound)
|
||||||
@@ -82,12 +78,7 @@ func newMessageID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMessage(w http.ResponseWriter, r *http.Request) {
|
func NewMessage(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method != http.MethodPost {
|
err := r.ParseMultipartForm(32 << 20)
|
||||||
http.Error(w, "Invalid request method", http.StatusMethodNotAllowed)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err := r.ParseForm()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Unable to parse form", http.StatusBadRequest)
|
http.Error(w, "Unable to parse form", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user