我正在使用 gorilla web toolkit 和 golang,并有以下代碼func test(w http.ResponseWriter, r *http.Request) { fmt.Println("test was called ..")}func main() { runtime.GOMAXPROCS(runtime.NumCPU()) mx := mux.NewRouter() mx.HandleFunc(?, test) http.ListenAndServe(":8080", mx)} 我的服務器將提供一個帶有表單的 html 文檔,該表單將執行獲取請求并發送“/?id={something}”。如何在 mx.HandleFunc 中設置模式以匹配查詢以便調用測試?我試過了:"/?id={something}, "/?id=", mx.HandleFunc("/", test).Queries("id")mx.HandleFunc("/", test).Methods("POST") (最后一個我更改了相應的頁面代碼,以便表單改為發布)。
- 1 回答
- 0 關注
- 193 瀏覽
添加回答
舉報
0/150
提交
取消