1

我正在尝试在 GAE 上部署我的第一个 golang 应用程序。由于某些原因,产品处理程序无法解决,我收到 404 错误。我错过了什么吗?

package test
import "github.com/gorilla/mux"
import (
    "fmt"
    "net/http"
)



func main() {
    r := mux.NewRouter()
    r.HandleFunc("/products", ProductsHandler)
    http.Handle("/", r)

       e := http.ListenAndServe(":8080", r)
    if e != nil {
      println(e.Error())
    }
}

func ProductsHandler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello, you!")
}
4

1 回答 1

3

继续 AppEngine 将自动侦听正确的端口并提供http.DefaultServeMux. 将您的功能更改main为 aninit并删除服务逻辑,您应该一切就绪。

阅读有关请求和 HTTP 的入门部分以获取更多详细信息。

于 2014-02-08T00:38:26.623 回答