gin/examples/app-engine/hello.go
2016-02-17 10:45:44 +08:00

24 lines
460 B
Go

package hello
import (
"github.com/gin-gonic/gin"
"net/http"
)
// 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)
}