Specify a new route to the router. You can choose any name for the route, but use the defined handler function — pageHandler.
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
router := gin.Default()
router.GET("/", indexHandler)
router.GET("/ping", pingHandler)
// your route here
router.Run("127.0.0.1:8080")
}
func indexHandler(context *gin.Context) {
context.String(http.StatusOK, "Welcome!")
}
func pingHandler(context *gin.Context) {
context.String(http.StatusOK, "pong")
}
func pageHandler(context *gin.Context) {
context.String(http.StatusOK, "Service page")
}