Enhance server functionality: add versioning support, implement command handling improvements, and introduce new Lua scripts for command execution

This commit is contained in:
alex
2025-06-23 01:26:16 +03:00
parent 03195dca59
commit 241809025d
12 changed files with 369 additions and 63 deletions

View File

@@ -17,18 +17,9 @@ type ServerV1UtilsContract interface {
ErrNotFound(w http.ResponseWriter, r *http.Request)
}
type ServerV1Contract interface {
ServerV1UtilsContract
Handle(w http.ResponseWriter, r *http.Request)
HandleList(w http.ResponseWriter, r *http.Request)
_handle()
_handleList()
}
// structure only for initialization
type HandlerV1InitStruct struct {
Ver string
Log slog.Logger
Config *config.ConfigConf
AllowedCmd *regexp.Regexp
@@ -45,6 +36,8 @@ type HandlerV1 struct {
allowedCmd *regexp.Regexp
listAllowedCmd *regexp.Regexp
ver string
}
func InitV1Server(o *HandlerV1InitStruct) *HandlerV1 {
@@ -53,6 +46,7 @@ func InitV1Server(o *HandlerV1InitStruct) *HandlerV1 {
cfg: o.Config,
allowedCmd: o.AllowedCmd,
listAllowedCmd: o.ListAllowedCmd,
ver: o.Ver,
}
}
@@ -67,3 +61,7 @@ func (h *HandlerV1) HandleList(w http.ResponseWriter, r *http.Request) {
h.r = r
h._handleList()
}
func (h *HandlerV1) GetVersion() string {
return h.ver
}