initial main file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
4a907383a0
commit
199e5b0cfb
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"github.com/gin-gonic/gin"
|
||||
api "github.com/appleboy/gin-status-api"
|
||||
)
|
||||
|
||||
func rootHandler(context *gin.Context) {
|
||||
context.JSON(http.StatusOK, gin.H{
|
||||
"text": "hello world",
|
||||
})
|
||||
}
|
||||
|
||||
func GetMainEngine() *gin.Engine {
|
||||
r := gin.New()
|
||||
|
||||
// Global middleware
|
||||
r.Use(gin.Logger())
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
r.GET("/api/status", api.StatusHandler)
|
||||
r.GET("/", rootHandler)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func main() {
|
||||
GetMainEngine().Run(":8088")
|
||||
}
|
Loading…
Reference in New Issue