- api/admin/v1 拆 base/system/admin 三子包,路由前缀 /admin/v1/{base,system,admin}
- system: auth/menu/role;admin: 管理员;base: log
- controller 改 import 子包;006_menu_paths_v2.sql 更新接口路径映射
- 权限码与路由分离,permission 标识不变
- 冒烟测试新路径 8 接口全通过
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
// Package base 定义基础常规接口(服务器日志监控等),路由前缀 /admin/v1/base。
|
|
package base
|
|
|
|
import "github.com/gogf/gf/v2/frame/g"
|
|
|
|
// LogFile describes one server log file.
|
|
type LogFile struct {
|
|
Name string `json:"name"` // file name
|
|
Path string `json:"path"` // path relative to the log dir
|
|
Size int64 `json:"size"` // bytes
|
|
ModTime string `json:"modTime"` // 2006-01-02 15:04:05
|
|
}
|
|
|
|
// LogFilesReq lists the server log files.
|
|
type LogFilesReq struct {
|
|
g.Meta `path:"/base/log/files" method:"get" tags:"Admin/Base/Log" summary:"List server log files"`
|
|
}
|
|
|
|
// LogFilesRes is the response of LogFilesReq.
|
|
type LogFilesRes struct {
|
|
Dir string `json:"dir"`
|
|
Files []*LogFile `json:"files"`
|
|
}
|
|
|
|
// LogTailReq reads the tail of a log file with optional keyword filter.
|
|
type LogTailReq struct {
|
|
g.Meta `path:"/base/log/tail" method:"get" tags:"Admin/Base/Log" summary:"Tail a server log file"`
|
|
File string `json:"file" v:"required#file required"` // relative to the log dir; path traversal is rejected
|
|
Lines int `json:"lines" d:"200" v:"min:1|max:2000"`
|
|
Keyword string `json:"keyword"` // substring filter
|
|
}
|
|
|
|
// LogTailRes is the response of LogTailReq.
|
|
type LogTailRes struct {
|
|
Lines []string `json:"lines"`
|
|
}
|