Refactor internal server structure: remove v1 package and migrate functionality to a new v1 module; update dependencies and improve command handling.

This commit is contained in:
alex
2025-06-22 17:01:14 +03:00
parent 213db0b8c7
commit c15e6c5b15
8 changed files with 11 additions and 11 deletions

56
internal/v1/server.go Normal file
View File

@@ -0,0 +1,56 @@
package v1
import (
"log/slog"
"net/http"
"regexp"
"github.com/akyaiy/GoSally-mvp/internal/config"
)
type ServerV1UtilsContract interface {
extractDescriptionStatic(path string) (string, error)
writeJSONError(status int, msg string)
newUUID() string
_errNotFound()
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()
}
type HandlerV1 struct {
w http.ResponseWriter
r *http.Request
log slog.Logger
cfg *config.ConfigConf
allowedCmd *regexp.Regexp
listAllowedCmd *regexp.Regexp
}
func InitV1Server(o *HandlerV1) *HandlerV1 {
return o
}
func (h *HandlerV1) Handle(w http.ResponseWriter, r *http.Request) {
h.w = w
h.r = r
h._handle()
}
func (h *HandlerV1) HandleList(w http.ResponseWriter, r *http.Request) {
h.w = w
h.r = r
h._handleList()
}