diff --git a/examples/app-engine/README.md b/examples/app-engine/README.md new file mode 100644 index 0000000..48505de --- /dev/null +++ b/examples/app-engine/README.md @@ -0,0 +1,7 @@ +# Guide to run Gin under App Engine LOCAL Development Server + +1. Download, install and setup Go in your computer. (That includes setting your `$GOPATH`.) +2. Download SDK for your platform from here: `https://developers.google.com/appengine/downloads?hl=es#Google_App_Engine_SDK_for_Go` +3. Download Gin source code using: `$ go get github.com/gin-gonic/gin` +4. Navigate to examples folder: `$ cd $GOPATH/src/github.com/gin-gonic/gin/examples/` +5. Run it: `$ goapp serve app-engine/` \ No newline at end of file diff --git a/examples/app-engine/app.yaml b/examples/app-engine/app.yaml new file mode 100644 index 0000000..5f20cf3 --- /dev/null +++ b/examples/app-engine/app.yaml @@ -0,0 +1,8 @@ +application: hello +version: 1 +runtime: go +api_version: go1 + +handlers: +- url: /.* + script: _go_app \ No newline at end of file diff --git a/examples/app-engine/hello.go b/examples/app-engine/hello.go new file mode 100644 index 0000000..f5daf82 --- /dev/null +++ b/examples/app-engine/hello.go @@ -0,0 +1,23 @@ +package hello + +import ( + "net/http" + "github.com/gin-gonic/gin" +) + +// This function's name is a must. App Engine uses it to drive the requests properly. +func init() { + // Starts a new Gin instance with no middle-ware + r := gin.New() + + // Define your handlers + r.GET("/", func(c *gin.Context){ + c.String(200, "Hello World!") + }) + r.GET("/ping", func(c *gin.Context){ + c.String(200, "pong") + }) + + // Handle all requests using net/http + http.Handle("/", r) +} \ No newline at end of file