Kaynağa Gözat

Added Google App Engine Example

Javier Provecho Fernandez 11 yıl önce
ebeveyn
işleme
6b5e80901f
2 değiştirilmiş dosya ile 30 ekleme ve 0 silme
  1. 8 0
      examples/app-engine/app.yaml
  2. 22 0
      examples/app-engine/hello.go

+ 8 - 0
examples/app-engine/app.yaml

@@ -0,0 +1,8 @@
+application: hello
+version: 1
+runtime: go
+api_version: go1
+
+handlers:
+- url: /.*
+  script: _go_app

+ 22 - 0
examples/app-engine/hello.go

@@ -0,0 +1,22 @@
+package hello
+
+import (
+	"net/http"
+	"github.com/gin-gonic/gin"
+)
+
+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)
+}