'Gorilla mux routing to the wrong handler

I'm practicing with a simple CRUD rest API in Go, I'm finally done with some basic boilerplate (I'm might switch to GORM), but I noticed that mux is not properlly routing my POST method handler. If I were to post to /inventory I instead receive all the items on my DB.

func RegisterItemsRouter(router *mux.Router) {
    itemsRouter := router.PathPrefix("/inventory").Subrouter()

    itemsRouter.HandleFunc("/", addItem).Methods(http.MethodPost)
    itemsRouter.HandleFunc("/", getItems).Methods(http.MethodGet)
    itemsRouter.HandleFunc("/{id:[0-9]+}", getItemById).Methods(http.MethodGet)
    itemsRouter.HandleFunc("/{id}", deleteItem).Methods(http.MethodDelete)
    itemsRouter.HandleFunc("/{id}", updateItem).Methods(http.MethodPut)
}

Here's how it looks like in postman

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source