gin/examples/app-engine/hello.go

25 lines
461 B
Go
Raw Normal View History

2014-07-02 20:08:37 +00:00
package hello
import (
2016-02-17 02:45:44 +00:00
"net/http"
2017-06-12 02:40:15 +00:00
"github.com/gin-gonic/gin"
2014-07-02 20:08:37 +00:00
)
// This function's name is a must. App Engine uses it to drive the requests properly.
2014-07-02 20:08:37 +00:00
func init() {
// Starts a new Gin instance with no middle-ware
r := gin.New()
// Define your handlers
2016-02-17 02:45:44 +00:00
r.GET("/", func(c *gin.Context) {
2014-07-02 20:08:37 +00:00
c.String(200, "Hello World!")
})
2016-02-17 02:45:44 +00:00
r.GET("/ping", func(c *gin.Context) {
2014-07-02 20:08:37 +00:00
c.String(200, "pong")
})
// Handle all requests using net/http
http.Handle("/", r)
2016-02-17 02:45:44 +00:00
}