For example, I have a func that handles "/items/{item-id}" and another func that handles "/items/request-task". How to make the first func ignores "/items/request-task" and match the rest?
Asked
Active
Viewed 277 times
1 Answers
0
like this.
package main
import (
"net/http"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/items/request-task", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("task."))
}) // task HandleFunc before other
r.HandleFunc("/items/{item-id}", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("other."))
})
http.Handle("/", r)
http.ListenAndServe(":8080", nil)
}

No_20
- 101
- 3