看板 Programming 關於我們 聯絡資訊
在web server, url routing時, 有下面的做法來匹配 例如用 gorilla/mux r := mux.NewRouter() r.HandleFunc("/products/{key}", ProductHandler) r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler) r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler) 如果 url是 /articles/fiction/ 就會執行 ArticlesCategoryHandler 如果是 /articles/fictions/123 就會執行 ArticleHandler 但要是我的url是 /articles/fiction/steven/2013/09/12/en 有辦法讓category match /fiction/steven/2013/09/12/en/ 嗎? 看了許多的sample code都沒看見有辦法這樣match的.... 不知道各位是否有過類似的經驗 謝謝各位的幫忙 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.136.198.69 ※ 文章網址: https://www.ptt.cc/bbs/Programming/M.1515486220.A.6D8.html
tommady: 一層一層打下去囉 42.115.102.87 01/11 21:43