Ai
2 Star 5 Fork 0

SillyMan/Ping多个主机的Web版本

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
SillyMan 提交于 2021-01-07 21:48 +08:00 . first commit
package main
import (
"fmt"
"gitee.com/sillyman/mixlog"
"github.com/labstack/echo/v4"
"gitee.com/sillyman/PingHostsWebView/api"
. "gitee.com/sillyman/PingHostsWebView/modules/config"
)
const (
APPTitle = "PING监视器"
CompanyName = "xx有限公司"
CompanyShortName = "xx"
CompanyWebsite = "http://www.xxx.com.cn/"
CompanyDescr = "xx是国内一流的xx产品厂家。"
)
func main() {
e := echo.New()
mustSetEcho(e, Cfg.Debug)
mixlog.Info("已设置 WEB 引擎")
// 注册 APIs 路由
e.GET("/hosts", api.GetHosts)
e.GET("/hosts/:ip", api.GetHost)
e.GET("/hosts/running/ip_addresses", api.GetRunningHostsIPs)
e.POST("/hosts", api.AddHost)
e.PUT("/hosts/:ip", api.UpdateHost)
e.DELETE("/hosts/:ip", api.DelHost)
e.PATCH("/hosts/is_running/:ip", api.SetHostRunningStatus)
e.GET("/pingers/summaries", api.GetPingSummaries)
e.DELETE("/pingers/summaries", api.ClearAllSummaries)
e.PATCH("/pingers/summaries/comment/:ip", api.SetPingSummaryComment)
e.GET("/ws/pingers/summaries", api.WsBroLatestPingSummaries)
e.GET("/ping/records/count/:ip", api.CountPingRecords)
e.GET("/ping/records/:ip", api.GetPingRecords)
mixlog.Debug("已经注册APIs路由")
// 前端页面
e.GET("/", func(c echo.Context) error {
return c.Render(200, "index.html", echo.Map{
"title": APPTitle,
"companyName": CompanyName,
"shortCompanyName": CompanyShortName,
"companyWebsite": CompanyWebsite,
})
})
mixlog.Debug("已经注册前端页面")
mixlog.Infof("WEB 服务开始监听:%s", Cfg.HTTPListeningOnAddr)
fmt.Println("==============================")
fmt.Printf("本软件由%s开发,供客户免费使用。\n", CompanyShortName)
fmt.Println(CompanyDescr)
fmt.Printf("公司官网:%s\n", CompanyWebsite)
fmt.Println("==============================")
e.Logger.Fatal(e.Start(Cfg.HTTPListeningOnAddr))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/sillyman/PingHostsWebView.git
git@gitee.com:sillyman/PingHostsWebView.git
sillyman
PingHostsWebView
Ping多个主机的Web版本
11e63cd92578

搜索帮助