Dou*_*sek 1 google-app-engine url-routing go
在Google App Engine with Go中,我想采用这样的网址:
http://www.example.com/api/account/123456/product/573832
Run Code Online (Sandbox Code Playgroud)
并像这样对待它:
http://www.example.com/api/account/{acctId}/product/{prodId}
Run Code Online (Sandbox Code Playgroud)
然后访问acctId
并prodId
在我的处理函数中.
我该怎么做呢?
你在这:
func httpHandle(httpResponse http.ResponseWriter, httpRequest *http.Request) {
urlPart := strings.Split(httpRequest.URL.Path, "/")
// urlPart[3] is the acctId, urlPart[5] is the prodId
}
Run Code Online (Sandbox Code Playgroud)