mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 20:12:25 +00:00
Compare commits
2 Commits
8e017af3ed
...
d4413c433f
| Author | SHA1 | Date | |
|---|---|---|---|
| d4413c433f | |||
| d9a4bb7871 |
26
Makefile
26
Makefile
@@ -55,30 +55,22 @@ pure-run:
|
|||||||
exec ./$(BIN_DIR)/$(APP_NAME)
|
exec ./$(BIN_DIR)/$(APP_NAME)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@go test ./... | grep -v '^?' || true
|
@cd src && go test ./... | grep -v '^?' || true
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@go fmt ./internal/./...
|
@cd src && go fmt .
|
||||||
@go fmt ./cmd/./...
|
@cd src && $(GOPATH)/bin/goimports -w .
|
||||||
@go fmt ./hooks/./...
|
|
||||||
@$(GOPATH)/bin/goimports -w ./internal/
|
|
||||||
@$(GOPATH)/bin/goimports -w ./cmd/
|
|
||||||
@$(GOPATH)/bin/goimports -w ./hooks/
|
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
@go vet ./...
|
@cd src && go vet ./...
|
||||||
|
|
||||||
lint:
|
|
||||||
@$(GOPATH)/bin/golangci-lint run
|
|
||||||
|
|
||||||
check: fmt vet lint test
|
check: fmt vet lint test
|
||||||
|
lint:
|
||||||
licenses:
|
@cd src && $(GOPATH)/bin/golangci-lint run ./...
|
||||||
@$(GOPATH)/bin/go-licenses save ./... --save_path=third_party/licenses --force
|
@$(GOPATH)/bin/go-licenses save ./... --save_path=third_party/licenses --force
|
||||||
@echo "Licenses have been exported to third_party/licenses"
|
@echo "Licenses have been exported to third_party/licenses"
|
||||||
|
|
||||||
clean:
|
licenses:
|
||||||
@rm -rf bin
|
@cd src && $(GOPATH)/bin/go-licenses save ./... --save_path=../third_party/licenses --force
|
||||||
|
@echo "Licenses have been exported to third_party/licenses"
|
||||||
help:
|
help:
|
||||||
@echo "Available commands: $$(cat Makefile | grep -E '^[a-zA-Z_-]+:.*?' | grep -v -- '-setup:' | sed 's/:.*//g' | sort | uniq | tr '\n' ' ')"
|
@echo "Available commands: $$(cat Makefile | grep -E '^[a-zA-Z_-]+:.*?' | grep -v -- '-setup:' | sed 's/:.*//g' | sort | uniq | tr '\n' ' ')"
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/core/corestate"
|
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/colors"
|
"github.com/akyaiy/GoSally-mvp/src/internal/colors"
|
||||||
|
"github.com/akyaiy/GoSally-mvp/src/internal/core/corestate"
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/core/run_manager"
|
"github.com/akyaiy/GoSally-mvp/src/internal/core/run_manager"
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/core/update"
|
"github.com/akyaiy/GoSally-mvp/src/internal/core/update"
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/core/utils"
|
"github.com/akyaiy/GoSally-mvp/src/internal/core/utils"
|
||||||
@@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/akyaiy/GoSally-mvp/src/internal/server/gateway"
|
"github.com/akyaiy/GoSally-mvp/src/internal/server/gateway"
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/server/session"
|
"github.com/akyaiy/GoSally-mvp/src/internal/server/session"
|
||||||
"github.com/akyaiy/GoSally-mvp/src/internal/server/sv1"
|
"github.com/akyaiy/GoSally-mvp/src/internal/server/sv1"
|
||||||
|
"github.com/akyaiy/GoSally-mvp/src/internal/server/sv2"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/cors"
|
"github.com/go-chi/cors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -65,13 +66,20 @@ func RunHook(ctx context.Context, cs *corestate.CoreState, x *app.AppX) error {
|
|||||||
Ver: "v1",
|
Ver: "v1",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sv2 := sv2.InitServer(&sv2.HandlerInitStruct{
|
||||||
|
X: x,
|
||||||
|
CS: cs,
|
||||||
|
AllowedCmd: regexp.MustCompile(AllowedCmdPattern),
|
||||||
|
Ver: "v2",
|
||||||
|
})
|
||||||
|
|
||||||
session_manager := session.New(*x.Config.Conf.HTTPServer.SessionTTL)
|
session_manager := session.New(*x.Config.Conf.HTTPServer.SessionTTL)
|
||||||
|
|
||||||
s := gateway.InitGateway(&gateway.GatewayServerInit{
|
s := gateway.InitGateway(&gateway.GatewayServerInit{
|
||||||
SM: session_manager,
|
SM: session_manager,
|
||||||
CS: cs,
|
CS: cs,
|
||||||
X: x,
|
X: x,
|
||||||
}, serverv1)
|
}, serverv1, sv2)
|
||||||
|
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
r.Use(cors.Handler(cors.Options{
|
r.Use(cors.Handler(cors.Options{
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ type LuaEngineDeps struct {
|
|||||||
|
|
||||||
type LuaEngineContract interface {
|
type LuaEngineContract interface {
|
||||||
Handle(deps *LuaEngineDeps) *rpc.RPCResponse
|
Handle(deps *LuaEngineDeps) *rpc.RPCResponse
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type LuaEngine struct {
|
type LuaEngine struct {
|
||||||
|
|||||||
12
src/internal/server/sv2/handle.go
Normal file
12
src/internal/server/sv2/handle.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package sv2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/akyaiy/GoSally-mvp/src/internal/server/rpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (h *Handler) Handle(_ context.Context, sid string, r *http.Request, req *rpc.RPCRequest) *rpc.RPCResponse {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
43
src/internal/server/sv2/server.go
Normal file
43
src/internal/server/sv2/server.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// SV2 works with binaries, scripts, and anything else that has access to stdin/stdout.
|
||||||
|
// Modules run in a separate process and communicate via I/O.
|
||||||
|
package sv2
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/akyaiy/GoSally-mvp/src/internal/core/corestate"
|
||||||
|
"github.com/akyaiy/GoSally-mvp/src/internal/engine/app"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HandlerV2InitStruct structure is only for initialization
|
||||||
|
type HandlerInitStruct struct {
|
||||||
|
Ver string
|
||||||
|
CS *corestate.CoreState
|
||||||
|
X *app.AppX
|
||||||
|
AllowedCmd *regexp.Regexp
|
||||||
|
}
|
||||||
|
|
||||||
|
type Handler struct {
|
||||||
|
cs *corestate.CoreState
|
||||||
|
x *app.AppX
|
||||||
|
|
||||||
|
// allowedCmd and listAllowedCmd are regular expressions used to validate command names.
|
||||||
|
allowedCmd *regexp.Regexp
|
||||||
|
|
||||||
|
ver string
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitServer(o *HandlerInitStruct) *Handler {
|
||||||
|
return &Handler{
|
||||||
|
cs: o.CS,
|
||||||
|
x: o.X,
|
||||||
|
allowedCmd: o.AllowedCmd,
|
||||||
|
ver: o.Ver,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVersion returns the API version of the HandlerV1, which is set during initialization.
|
||||||
|
// This version is used to identify the API version in the request routing.
|
||||||
|
func (h *Handler) GetVersion() string {
|
||||||
|
return h.ver
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user