mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
0.7.0
This commit is contained in:
parent
7382d7efce
commit
289f94dbfa
@ -34,13 +34,14 @@ func Run() {
|
||||
gweb.RegisterController(method.GET, "/**/*.png", html.StaticFileController)
|
||||
|
||||
// 控制器
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/log/add", controller.JsonLogAddController) // 添加日志
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/log/search", controller.LogSearchController) // 查询日志
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/names", controller.StorageNamesController) // 查询日志仓名称列表
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/list", controller.StorageListController) // 查询日志仓信息列表
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/delete", controller.StorageDeleteController) // 删除日志仓
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/user/enableLogin", controller.IsEnableLoginController) // 查询是否开启用户密码登录功能
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/user/login", controller.LoginController) // Login
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/log/add", controller.JsonLogAddController) // 添加日志
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/log/transferAdd", controller.JsonLogTransferAddController) // 日志数据转发添加日志
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/log/search", controller.LogSearchController) // 查询日志
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/names", controller.StorageNamesController) // 查询日志仓名称列表
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/list", controller.StorageListController) // 查询日志仓信息列表
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/store/delete", controller.StorageDeleteController) // 删除日志仓
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/user/enableLogin", controller.IsEnableLoginController) // 查询是否开启用户密码登录功能
|
||||
gweb.RegisterController(method.POST, contextPath+"/v1/user/login", controller.LoginController) // Login
|
||||
|
||||
// 默认引擎空转一下,触发未建索引继续建
|
||||
go ldb.NewDefaultEngine().AddTextLog("", "", "")
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
package onstart
|
||||
|
||||
const VERSION = "glogcenter 0.6.0"
|
||||
const VERSION = "glogcenter 0.7.0"
|
||||
|
||||
@ -38,11 +38,34 @@ func JsonLogAddController(req *gweb.HttpRequest) *gweb.HttpResult {
|
||||
return gweb.Ok()
|
||||
}
|
||||
|
||||
// 添加日志(来自数据转发)
|
||||
func JsonLogTransferAddController(req *gweb.HttpRequest) *gweb.HttpResult {
|
||||
|
||||
// 开启API秘钥校验时才检查
|
||||
if conf.IsEnableSecurityKey() {
|
||||
auth := req.GetHeader(conf.GetHeaderSecurityKey())
|
||||
if auth != conf.GetSecurityKey() {
|
||||
return gweb.Error(403, "未经授权的访问,拒绝服务")
|
||||
}
|
||||
}
|
||||
|
||||
md := &logdata.LogDataModel{}
|
||||
err := req.BindJSON(md)
|
||||
if err != nil {
|
||||
log.Println("请求参数有误", err)
|
||||
return gweb.Error500(err.Error())
|
||||
}
|
||||
|
||||
engine := ldb.NewDefaultEngine()
|
||||
engine.AddTextLog(md.Date, md.Text, md.System)
|
||||
return gweb.Ok()
|
||||
}
|
||||
|
||||
// 转发其他GLC服务
|
||||
func transferGlc(md *logdata.LogDataModel) {
|
||||
hosts := conf.GetSlaveHosts()
|
||||
for i := 0; i < len(hosts); i++ {
|
||||
go httpPostJson(hosts[i]+conf.GetContextPath()+"/v1/log/add", md.ToJson())
|
||||
go httpPostJson(hosts[i]+conf.GetContextPath()+"/v1/log/transferAdd", md.ToJson())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user