From 199e5b0cfb3352211fda8f3585491b5f33bd7720 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 24 Mar 2016 17:01:43 +0800 Subject: [PATCH] initial main file. Signed-off-by: Bo-Yi Wu --- main.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..8f0d4bf --- /dev/null +++ b/main.go @@ -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") +}