working commit

This commit is contained in:
2026-02-02 17:27:16 +02:00
parent 0dac88fde8
commit 41e1b253f7
6 changed files with 160 additions and 67 deletions
+3
View File
@@ -1,6 +1,8 @@
package handler
import (
"net/http"
"mstore/app/operator"
"mstore/app/router"
)
@@ -10,5 +12,6 @@ func (hand *Handler) SendHello(rctx *router.Context) {
params := &operator.SendHelloParams{}
res, _ := hand.oper.SendHello(params)
rctx.SetStatus(http.StatusOK)
hand.SendResult(rctx, res)
}
+6 -6
View File
@@ -7,11 +7,11 @@ import (
)
type Context struct {
Ctx context.Context
Request *http.Request
Writer http.ResponseWriter
PathMap map[string]string
StatusCode int
Ctx context.Context
Request *http.Request
Writer http.ResponseWriter
PathMap map[string]string
StatusCode int
}
func NewContext(writer http.ResponseWriter, request *http.Request) *Context {
@@ -30,7 +30,7 @@ func (rctx *Context) SetHeader(key, value string) {
}
func (rctx *Context) SetStatus(httpStatus int) {
rctx.StatusCode = httpStatus
rctx.StatusCode = httpStatus
rctx.Writer.WriteHeader(httpStatus)
}
+5
View File
@@ -55,6 +55,11 @@ func (svc *Service) Build() error {
svc.logg.Infof("Service build ")
svc.rout = router.NewRouter()
svc.rout.Use(router.NewRecoveryMiddleware(svc.logg.Errorf))
svc.rout.Use(router.NewLoggingMiddleware(svc.logg.Infof))
svc.rout.Use(router.NewCorsMiddleware())
svc.rout.Get("/v3/api/service/hello", svc.hand.SendHello)
svc.rout.Head("/v3/api/file/{filepath}", svc.hand.FileExists)