代码拉取完成,页面将自动刷新
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))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。