mirror of
https://github.com/golang/go
synced 2024-11-05 20:16:13 -07:00
8f8fd1f239
The default timeout for urlfetch requests on App Engine Classic is 5 seconds. Sometimes the requests can take longer, so increase it to the maximum value of 60 seconds. The playground has its own timeout for running code so there's no need to impose a second level of protection. Also cleans up the code to remove old appenginevm code and use the correct imports. Change-Id: I15da96e5ba70fb008bf821f4609f431847662223 Reviewed-on: https://go-review.googlesource.com/129395 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
35 lines
760 B
Go
35 lines
760 B
Go
// Copyright 2012 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build appengine
|
|
|
|
package playground
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
|
|
"google.golang.org/appengine"
|
|
"google.golang.org/appengine/log"
|
|
"google.golang.org/appengine/urlfetch"
|
|
)
|
|
|
|
func init() {
|
|
onAppengine = !appengine.IsDevAppServer()
|
|
}
|
|
|
|
func contextFunc(r *http.Request) context.Context {
|
|
return appengine.NewContext(r)
|
|
}
|
|
|
|
func post(ctx context.Context, url, contentType string, body io.Reader) (*http.Response, error) {
|
|
return urlfetch.Client(ctx).Post(url, contentType, body)
|
|
}
|
|
|
|
func report(r *http.Request, err error) {
|
|
ctx := appengine.NewContext(r)
|
|
log.Errorf(ctx, "%v", err)
|
|
}
|