大猩猩Mux“匹配任何东西”路径模板

What is the proper syntax to create a simple "match anything" handler?

mux.NewRouter().StrictSlash(true).Path("/")....

The above code seems to strictly match / and /foo won't get matched

This should work:

router := mux.NewRouter().PathPrefix("/")

You can use mux.Route.HandlerFunc together with mux.Router.PathPrefix:

r := mux.NewRouter()

// route catalog to catalogHandler:
r.HandleFunc("/catalog/{id}", catalogHandler) 

// route everything else to defaultHandler:
r.PathPrefix("/").HandlerFunc(defaultHandler)

Note the difference in names (HandlerFunc vs HandleFunc).