modularization
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"jottyfan.de/learngin/modules"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EchoRequest struct {
|
type EchoRequest struct {
|
||||||
@@ -14,9 +15,7 @@ func main() {
|
|||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.LoadHTMLGlob("templates/*")
|
r.LoadHTMLGlob("templates/*")
|
||||||
|
|
||||||
r.GET("/ping", func(c *gin.Context) {
|
r.GET("/ping", modules.Ping)
|
||||||
c.JSON(http.StatusOK, gin.H{"message": "pong"})
|
|
||||||
})
|
|
||||||
|
|
||||||
r.GET("/", func(c *gin.Context) {
|
r.GET("/", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "index.html", nil)
|
c.HTML(http.StatusOK, "index.html", nil)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package modules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Ping(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "pong"})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user