我正在使用Go开发REST API,但我不知道如何进行路径映射并从中检索路径参数.
我想要这样的东西:
func main() {
http.HandleFunc("/provisions/:id", Provisions) //<-- How can I map "id" parameter in the path?
http.ListenAndServe(":8080", nil)
}
func Provisions(w http.ResponseWriter, r *http.Request) {
//I want to retrieve here "id" parameter from request
}
Run Code Online (Sandbox Code Playgroud)
http如果有可能的话,我想只使用包而不是web框架.
谢谢.
go ×1