Last active
August 29, 2015 14:23
-
-
Save pokstad/828d0775a2458ce610fc to your computer and use it in GitHub Desktop.
Google App Engine Sandbox Module for Dispatch Demo
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
# make sure to replace "projectid" below with the project ID configured in the Google Developer Console | |
application: projectid | |
version: 1 | |
runtime: go | |
api_version: go1 | |
module: module2 | |
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
dispatch: | |
# Module 2 only responds to requests with a path starting with "/module2" | |
- url: "*/module2/*" | |
module: module2 | |
# All other traffic is routed to the first module | |
- url: "*/*" | |
module: module1 |
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
// 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. | |
package main | |
import ( | |
"html/template" | |
"net/http" | |
"time" | |
"google.golang.org/appengine" | |
"google.golang.org/appengine/log" | |
) | |
var initTime = time.Now() | |
func init() { | |
http.HandleFunc("/module2/", handle1) | |
appengine.Main() | |
} | |
func handle(w http.ResponseWriter, r *http.Request) { | |
c := appengine.NewContext(r) | |
log.Infof(c, "Serving the front page.") | |
tmpl.Execute(w, time.Since(initTime)) | |
} | |
var tmpl = template.Must(template.New("front").Parse(` | |
<html><body> | |
<p> | |
Hello, Module2! 세상아 안녕! | |
</p> | |
<p> | |
This instance has been running for <em>{{.}}</em>. | |
</p> | |
</body></html> | |
`)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment