initial import

This commit is contained in:
2026-01-23 14:41:49 +02:00
commit 772657d9be
37 changed files with 11382 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
package handler
import (
"mstore/app/operator"
"mstore/app/router"
)
func (hand *Handler) FileExists(rctx *router.Context) {
hand.logg.Debugf("handle FileExists")
params := &operator.FileExistsParams{}
res, _ := hand.oper.FileExists(params)
rctx.SetStatus(res.Code)
}
+24
View File
@@ -0,0 +1,24 @@
package handler
import (
"mstore/app/logger"
"mstore/app/operator"
)
type HandlerParams struct {
Operator *operator.Operator
}
type Handler struct {
oper *operator.Operator
logg *logger.Logger
}
func NewHandler(params *HandlerParams) (*Handler, error) {
var err error
hand := &Handler{
oper: params.Operator,
}
hand.logg = logger.NewLogger("handler")
return hand, err
}
+27
View File
@@ -0,0 +1,27 @@
package handler
import (
"mstore/app/router"
)
type Response struct {
Error bool `json:"error" yaml:"error"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Result any `json:"result,omitempty" yaml:"result,result"`
}
func (hand *Handler) SendResult(rctx *router.Context, result any) {
response := &Response{
Error: false,
Result: result,
}
rctx.SendJSON(response)
}
func (hand *Handler) SendError(rctx *router.Context, err error) {
response := &Response{
Error: true,
Message: err.Error(),
}
rctx.SendJSON(response)
}
+14
View File
@@ -0,0 +1,14 @@
package handler
import (
"mstore/app/operator"
"mstore/app/router"
)
func (hand *Handler) SendHello(rctx *router.Context) {
hand.logg.Debugf("handle sendHello")
params := &operator.SendHelloParams{}
res, _ := hand.oper.SendHello(params)
hand.SendResult(rctx, res)
}