hello.go 481 B

123456789101112131415161718192021222324
  1. package hello
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // This function's name is a must. App Engine uses it to drive the requests properly.
  7. func init() {
  8. // Starts a new Gin instance with no middle-ware
  9. r := gin.New()
  10. // Define your handlers
  11. r.GET("/", func(c *gin.Context) {
  12. c.String(http.StatusOK, "Hello World!")
  13. })
  14. r.GET("/ping", func(c *gin.Context) {
  15. c.String(http.StatusOK, "pong")
  16. })
  17. // Handle all requests using net/http
  18. http.Handle("/", r)
  19. }