第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

“PathPrefix”如何在 Go 的“gorilla.mux”庫中工作?

“PathPrefix”如何在 Go 的“gorilla.mux”庫中工作?

Go
狐的傳說 2021-06-15 02:08:48
我正在玩gorilla.muxGo的圖書館。我有以下配置,但我無法弄清楚到達(dá)該HelloWorldXml方法的 URL 。func main() {    router := mux.NewRouter()    router.HandleFunc("/{name}.xml", HelloWorldXml).           PathPrefix("/products/")    router.HandleFunc("/hello/{name}", HelloWorld)    http.Handle("/", router)    http.ListenAndServe(":8787",nil)}要使用的正確 URL 是什么? http://localhost:8787/products/MyName.xml返回 404。
查看完整描述

1 回答

?
守著一只汪

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個(gè)贊

 func main() {

    router := mux.NewRouter()

    router.HandleFunc("/{name}.xml", HelloWorldXml)

    subrouter := router.PathPrefix("/products/").Subrouter()

    //localhost/products/item.xml

    subrouter.HandleFunc("/{name}.xml", HelloWorldXmlHandler)

    router.HandleFunc("/hello/{name}", HelloWorld)

    http.Handle("/", router)

    http.ListenAndServe(":8787",nil)

}


查看完整回答
反對(duì) 回復(fù) 2021-06-28
  • 1 回答
  • 0 關(guān)注
  • 362 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)