-
-
Save qushot/f2c9f8c8723bd554c3b7923dbbb83334 to your computer and use it in GitHub Desktop.
ファイアウォールルール確認用GAEアプリケーション(Cron, Taskqueue対応版)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: YOUR_PROJECT_ID | |
version: X | |
runtime: go | |
api_version: go1.8 | |
handlers: | |
- url: /.* | |
script: _go_app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cron: | |
- description: cron jobs | |
url: /cron | |
schedule: every 1 hours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo | |
import ( | |
"fmt" | |
"net/http" | |
"google.golang.org/appengine" | |
"google.golang.org/appengine/log" | |
"google.golang.org/appengine/taskqueue" | |
) | |
func rootHandler(w http.ResponseWriter, r *http.Request) { | |
ctx := appengine.NewContext(r) | |
log.Infof(ctx, "Request from IP Address \"%v\"\n", r.RemoteAddr) | |
fmt.Fprintln(w, "hello") | |
t := taskqueue.NewPOSTTask("/task", nil) | |
taskqueue.Add(ctx, t, "myqueue") | |
} | |
func taskQueueHandler(w http.ResponseWriter, r *http.Request) { | |
ctx := appengine.NewContext(r) | |
log.Infof(ctx, "TaskQueue IP Address \"%v\"\n", r.RemoteAddr) | |
} | |
func cronHandler(w http.ResponseWriter, r *http.Request) { | |
ctx := appengine.NewContext(r) | |
log.Infof(ctx, "Cron IP Address \"%v\"\n", r.RemoteAddr) | |
} | |
func init() { | |
http.HandleFunc("/", rootHandler) | |
http.HandleFunc("/task", taskQueueHandler) | |
http.HandleFunc("/cron", cronHandler) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
queue: | |
- name: myqueue | |
rate: 1/s | |
max_concurrent_requests: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment