代码拉取完成,页面将自动刷新
package main
import (
"flag"
"fmt"
"log"
"monitorUtil/app"
"monitorUtil/auth"
"net/http"
"github.com/gin-gonic/gin"
)
// main is the entry point of the program.
func main() {
// cliPort is the port number for the command-line interface.
var cliPort = flag.String("p", "8080", "port")
// printVersion is a boolean flag indicating whether to print the program version.
var printVersion bool
flag.BoolVar(&printVersion, "v", false, "print program version")
flag.Parse()
// If printVersion is true, print the program version and exit.
if printVersion {
log.Println("V20220705")
log.Fatal("Program exited due to version request.")
}
// Create a new gin router.
r := gin.Default()
// Initialize Swagger.
initSwagger()
// Register routes to the router.
registerRoutes(r)
// Start the HTTP server.
err := http.ListenAndServe(fmt.Sprintf(":%s", *cliPort), r)
if err != nil {
log.Fatal("Failed to start server:", err)
}
}
// registerRoutes sets up the routes for the check API group.
func registerRoutes(r *gin.Engine) {
apiRoute := r.Group("/check")
apiRoute.Use(auth.CheckJWTWithIP(auth.GenerateKey()))
apiRoute.POST("/http-check", app.HttpCheck) // 更明确的路由名称
apiRoute.POST("/mysql-check", app.MysqlCheck)
apiRoute.POST("/oracle-check", app.OracleCheck)
apiRoute.POST("/port-check", app.PortCheck)
apiRoute.POST("/post-request", app.PostCheck) // 更明确的路由名称
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。