Project structure refactor:

- Change package name general_server to gateway
- Changing the structure of directories and packages
- Adding vendor to the project
This commit is contained in:
2025-07-28 20:16:40 +03:00
parent 19b699d92b
commit ec94df5f4a
786 changed files with 357010 additions and 357 deletions

View File

@@ -0,0 +1,29 @@
package rpc
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params RPCRequestParams `json:"params"`
}
type RPCRequestParams struct {
ContextVersion string `json:"context-version"`
Method map[string]any `json:"method-params"`
}
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Result any `json:"result"`
}
type RPCError struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Error any `json:"error"`
}
const (
JSONRPCVersion = "2.0"
)

View File

@@ -0,0 +1,39 @@
package rpc
import (
"encoding/json"
"net/http"
)
const (
ErrParseError = -32700
ErrParseErrorS = "Parse error"
ErrInvalidRequest = -32600
ErrInvalidRequestS = "Invalid Request"
ErrMethodNotFound = -32601
ErrMethodNotFoundS = "Method not found"
ErrInvalidParams = -32602
ErrInvalidParamsS = "Invalid params"
ErrInternalError = -32603
ErrInternalErrorS = "Internal error"
ErrContextVersion = -32010
ErrContextVersionS = "Invalid context version"
)
func WriteRouterError(w http.ResponseWriter, status int, e *RPCError) error {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
data, err := json.Marshal(e)
if err != nil {
return err
}
_, err = w.Write(data)
return err
}