Merge pull request #26 from javierprovecho/master
Added Google App Engine Example
This commit is contained in:
		
							
								
								
									
										7
									
								
								examples/app-engine/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								examples/app-engine/README.md
									
									
									
									
									
										Normal file
									
								
							@ -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/`
 | 
				
			||||||
							
								
								
									
										8
									
								
								examples/app-engine/app.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								examples/app-engine/app.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					application: hello
 | 
				
			||||||
 | 
					version: 1
 | 
				
			||||||
 | 
					runtime: go
 | 
				
			||||||
 | 
					api_version: go1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					handlers:
 | 
				
			||||||
 | 
					- url: /.*
 | 
				
			||||||
 | 
					  script: _go_app
 | 
				
			||||||
							
								
								
									
										23
									
								
								examples/app-engine/hello.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								examples/app-engine/hello.go
									
									
									
									
									
										Normal file
									
								
							@ -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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user