dousi7579 2015-06-01 17:42
浏览 64

在托管虚拟机的本地开发环境中运行Web应用程序时出现appengine.NewContext错误

I am trying to run one of the demos of the appengine using managed vm locally in my development environment. The requests fail with a panic when the code tries to create a new context for the request (appengine.NewContext(r)):

func handle(w http.ResponseWriter, r *http.Request) {
   if r.URL.Path != "/" {
    http.NotFound(w, r)
    return
   }

   c := appengine.NewContext(r)
   log.Infof(c, "Serving the front page.")
   tmpl.Execute(w, time.Since(initTime))
}

The appengine.NewContext(r) produces this error:

2015/05/30 01:01:27 appengine: NewContext passed an unknown http.Request 
2015/05/30 01:01:27 http: panic serving 192.168.59.3:51889: appengine: NewContext passed an unknown http.Request 
goroutine 115 [running]: 
net/http.func·011() 
 /usr/local/go/src/net/http/server.go:1130 +0xbb 
log.Panic(0xc2080c6b10, 0x1, 0x1) 
 /usr/local/go/src/log/log.go:307 +0xb9 
google.golang.org/appengine/internal.WithContext(0x7f7072110508, 0xc20800a380, 0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/internal/api.go:247 +0x158 
google.golang.org/appengine.WithContext(0x7f7072110508, 0xc20800a380, 0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/appengine.go:35 +0x4e 
google.golang.org/appengine.NewContext(0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/appengine.go:28 +0x7f 
main28149.handle(0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 helloworld.go:28 +0x8f 
net/http.HandlerFunc.ServeHTTP(0x8662e0, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1265 +0x41 

net/http.(*ServeMux).ServeHTTP(0xc208038e40, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1541 +0x17d 
net/http.serverHandler.ServeHTTP(0xc2080600c0, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1703 +0x19a 
net/http.(*conn).serve(0xc208062c80) 
 /usr/local/go/src/net/http/server.go:1204 +0xb57 
created by net/http.(*Server).Serve 
 /usr/local/go/src/net/http/server.go:1751 +0x35e

The Dockerfile is:

FROM gcr.io/google_appengine/go-compat
RUN rm -rf /goroot && mkdir /goroot && curl https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1
ADD . /app
RUN /bin/bash /app/_ah/build.sh

It seems like the appengine environment is not properly set up in the docker image.

I would appreciate any suggestion about how to solve this problem.

Thanks!

  • 写回答

1条回答 默认 最新

  • doushun9875 2015-06-02 03:46
    关注

    from Go App Engine for Managed VMs

    appengine.Context has been replaced with the Context type from golang.org/x/net/context.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?