Vendor dependencies for GCS
This commit is contained in:
parent
ba75a3884c
commit
8ca6a9a240
1228 changed files with 1769186 additions and 1 deletions
14
vendor/google.golang.org/appengine/demos/guestbook/app.yaml
generated
vendored
Normal file
14
vendor/google.golang.org/appengine/demos/guestbook/app.yaml
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Demo application for App Engine "flexible environment".
|
||||
runtime: go
|
||||
vm: true
|
||||
api_version: go1
|
||||
|
||||
handlers:
|
||||
# Favicon. Without this, the browser hits this once per page view.
|
||||
- url: /favicon.ico
|
||||
static_files: favicon.ico
|
||||
upload: favicon.ico
|
||||
|
||||
# Main app. All the real work is here.
|
||||
- url: /.*
|
||||
script: _go_app
|
BIN
vendor/google.golang.org/appengine/demos/guestbook/favicon.ico
generated
vendored
Normal file
BIN
vendor/google.golang.org/appengine/demos/guestbook/favicon.ico
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
109
vendor/google.golang.org/appengine/demos/guestbook/guestbook.go
generated
vendored
Normal file
109
vendor/google.golang.org/appengine/demos/guestbook/guestbook.go
generated
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This example only works on App Engine "flexible environment".
|
||||
// +build !appengine
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/appengine"
|
||||
"google.golang.org/appengine/datastore"
|
||||
"google.golang.org/appengine/log"
|
||||
"google.golang.org/appengine/user"
|
||||
)
|
||||
|
||||
var initTime time.Time
|
||||
|
||||
type Greeting struct {
|
||||
Author string
|
||||
Content string
|
||||
Date time.Time
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handleMainPage)
|
||||
http.HandleFunc("/sign", handleSign)
|
||||
appengine.Main()
|
||||
}
|
||||
|
||||
// guestbookKey returns the key used for all guestbook entries.
|
||||
func guestbookKey(ctx context.Context) *datastore.Key {
|
||||
// The string "default_guestbook" here could be varied to have multiple guestbooks.
|
||||
return datastore.NewKey(ctx, "Guestbook", "default_guestbook", 0, nil)
|
||||
}
|
||||
|
||||
var tpl = template.Must(template.ParseGlob("templates/*.html"))
|
||||
|
||||
func handleMainPage(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, "GET requests only", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := appengine.NewContext(r)
|
||||
tic := time.Now()
|
||||
q := datastore.NewQuery("Greeting").Ancestor(guestbookKey(ctx)).Order("-Date").Limit(10)
|
||||
var gg []*Greeting
|
||||
if _, err := q.GetAll(ctx, &gg); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Errorf(ctx, "GetAll: %v", err)
|
||||
return
|
||||
}
|
||||
log.Infof(ctx, "Datastore lookup took %s", time.Since(tic).String())
|
||||
log.Infof(ctx, "Rendering %d greetings", len(gg))
|
||||
|
||||
var email, logout, login string
|
||||
if u := user.Current(ctx); u != nil {
|
||||
logout, _ = user.LogoutURL(ctx, "/")
|
||||
email = u.Email
|
||||
} else {
|
||||
login, _ = user.LoginURL(ctx, "/")
|
||||
}
|
||||
data := struct {
|
||||
Greetings []*Greeting
|
||||
Login, Logout, Email string
|
||||
}{
|
||||
Greetings: gg,
|
||||
Login: login,
|
||||
Logout: logout,
|
||||
Email: email,
|
||||
}
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
if err := tpl.ExecuteTemplate(w, "guestbook.html", data); err != nil {
|
||||
log.Errorf(ctx, "%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func handleSign(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
http.Error(w, "POST requests only", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
ctx := appengine.NewContext(r)
|
||||
g := &Greeting{
|
||||
Content: r.FormValue("content"),
|
||||
Date: time.Now(),
|
||||
}
|
||||
if u := user.Current(ctx); u != nil {
|
||||
g.Author = u.String()
|
||||
}
|
||||
key := datastore.NewIncompleteKey(ctx, "Greeting", guestbookKey(ctx))
|
||||
if _, err := datastore.Put(ctx, key, g); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
// Redirect with 303 which causes the subsequent request to use GET.
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
7
vendor/google.golang.org/appengine/demos/guestbook/index.yaml
generated
vendored
Normal file
7
vendor/google.golang.org/appengine/demos/guestbook/index.yaml
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
indexes:
|
||||
|
||||
- kind: Greeting
|
||||
ancestor: yes
|
||||
properties:
|
||||
- name: Date
|
||||
direction: desc
|
26
vendor/google.golang.org/appengine/demos/guestbook/templates/guestbook.html
generated
vendored
Normal file
26
vendor/google.golang.org/appengine/demos/guestbook/templates/guestbook.html
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Guestbook Demo</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
{{with .Email}}You are currently logged in as {{.}}.{{end}}
|
||||
{{with .Login}}<a href="{{.}}">Sign in</a>{{end}}
|
||||
{{with .Logout}}<a href="{{.}}">Sign out</a>{{end}}
|
||||
</p>
|
||||
|
||||
{{range .Greetings }}
|
||||
<p>
|
||||
{{with .Author}}<b>{{.}}</b>{{else}}An anonymous person{{end}}
|
||||
on <em>{{.Date.Format "3:04pm, Mon 2 Jan"}}</em>
|
||||
wrote <blockquote>{{.Content}}</blockquote>
|
||||
</p>
|
||||
{{end}}
|
||||
|
||||
<form action="/sign" method="post">
|
||||
<div><textarea name="content" rows="3" cols="60"></textarea></div>
|
||||
<div><input type="submit" value="Sign Guestbook"></div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
10
vendor/google.golang.org/appengine/demos/helloworld/app.yaml
generated
vendored
Normal file
10
vendor/google.golang.org/appengine/demos/helloworld/app.yaml
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
runtime: go
|
||||
api_version: go1
|
||||
vm: true
|
||||
|
||||
handlers:
|
||||
- url: /favicon.ico
|
||||
static_files: favicon.ico
|
||||
upload: favicon.ico
|
||||
- url: /.*
|
||||
script: _go_app
|
BIN
vendor/google.golang.org/appengine/demos/helloworld/favicon.ico
generated
vendored
Normal file
BIN
vendor/google.golang.org/appengine/demos/helloworld/favicon.ico
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
50
vendor/google.golang.org/appengine/demos/helloworld/helloworld.go
generated
vendored
Normal file
50
vendor/google.golang.org/appengine/demos/helloworld/helloworld.go
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2014 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This example only works on App Engine "flexible environment".
|
||||
// +build !appengine
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"google.golang.org/appengine"
|
||||
"google.golang.org/appengine/log"
|
||||
)
|
||||
|
||||
var initTime = time.Now()
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/", handle)
|
||||
appengine.Main()
|
||||
}
|
||||
|
||||
func handle(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := appengine.NewContext(r)
|
||||
log.Infof(ctx, "Serving the front page.")
|
||||
|
||||
tmpl.Execute(w, time.Since(initTime))
|
||||
}
|
||||
|
||||
var tmpl = template.Must(template.New("front").Parse(`
|
||||
<html><body>
|
||||
|
||||
<p>
|
||||
Hello, World! 세상아 안녕!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This instance has been running for <em>{{.}}</em>.
|
||||
</p>
|
||||
|
||||
</body></html>
|
||||
`))
|
Loading…
Add table
Add a link
Reference in a new issue