1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package zsshrpc_server
- const (
- SvrLogLevel_DEBUG = 0
- SvrLogLevel_INFO = 1
- SvrLogLevel_WARNING = 2
- SvrLogLevel_ERROR = 3
- )
- type ZSshRpcChState int8
- const (
- ChannelState_IDLE ZSshRpcChState = 0
- ChannelState_WAIT_URI ZSshRpcChState = 1
- ChannelState_WAIT_JSON ZSshRpcChState = 2
- ChannelState_EXEC_HANDLER ZSshRpcChState = 3
- ChannelState_WAIT_JSON_READ ZSshRpcChState = 4
- )
- type ZSshRpcMethod int8
- const (
- RpcMethod_CALL ZSshRpcMethod = 0
- RpcMethod_ADD ZSshRpcMethod = 1
- RpcMethod_DEL ZSshRpcMethod = 2
- RpcMethod_GET ZSshRpcMethod = 3
- RpcMethod_SET ZSshRpcMethod = 4
- )
- const (
- ResponseStatusCode_OK = 200
- ResponseStatusCode_NO_CONTENT = 204
- ResponseStatusCode_METHOD_NOT_ALLOWED = 405
- ResponseStatusCode_NOT_FOUND = 404
- ResponseStatusCode_FORBIDDEN = 403
- ResponseStatusCode_INVALID_REQUEST = 400
- ResponseStatusCode_INTERNAL_ERROR = 500
- ResponseStatusCode_VERSION_NOT_SUPPORT = 505
- ResponseStatusCode_UNKNOWN = 600
- ResponseStatusCode_JSON_DECODE_ERROR = 601
- )
- func GetResponseStatusCodeString(code int) string {
- switch code {
- case 200:
- return "OK"
- case 204:
- return "NO_CONTENT"
- case 405:
- return "METHOD_NOT_ALLOWED"
- case 404:
- return "NOT_FOUND"
- case 403:
- return "FORBIDDEN"
- case 400:
- return "INVALID_REQUEST"
- case 500:
- return "INTERNAL_ERROR"
- case 505:
- return "VERSION_NOT_SUPPORT"
- case 601:
- return "JSON_DECODE_ERROR"
- default:
- return "UNKNOWN"
- }
- }
- func GetOperationMethodName(method ZSshRpcMethod) string {
- switch method {
- case RpcMethod_CALL:
- return "CALL"
- case RpcMethod_ADD:
- return "ADD"
- case RpcMethod_DEL:
- return "DEL"
- case RpcMethod_GET:
- return "GET"
- case RpcMethod_SET:
- return "SET"
- default:
- return "UNKNOWN"
- }
- }
|