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