mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2026-02-23 07:54:38 +01:00
formatted code with gofmt
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
"bufio"
|
||||
uuid "github.com/gofrs/uuid"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net"
|
||||
)
|
||||
|
||||
type JsonRpc2Client struct {
|
||||
@@ -14,37 +14,36 @@ type JsonRpc2Client struct {
|
||||
}
|
||||
|
||||
func NewJsonRpc2Client() *JsonRpc2Client {
|
||||
return &JsonRpc2Client{
|
||||
}
|
||||
return &JsonRpc2Client{}
|
||||
}
|
||||
|
||||
func (r *JsonRpc2Client) Dial(address string) error {
|
||||
var err error
|
||||
r.conn, err = net.Dial("tcp", address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *JsonRpc2Client) getRaw(command string, args interface{}) (string, error) {
|
||||
type Request struct {
|
||||
JsonRpc string `json:"jsonrpc"`
|
||||
Method string `json:"method"`
|
||||
Id string `json:"id"`
|
||||
Params interface{} `json:"params,omitempty"`
|
||||
JsonRpc string `json:"jsonrpc"`
|
||||
Method string `json:"method"`
|
||||
Id string `json:"id"`
|
||||
Params interface{} `json:"params,omitempty"`
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Code int `json:"code"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Id string `json:"id"`
|
||||
Id string `json:"id"`
|
||||
Result json.RawMessage `json:"result"`
|
||||
Err Error `json:"error"`
|
||||
Err Error `json:"error"`
|
||||
}
|
||||
|
||||
u, err := uuid.NewV4()
|
||||
@@ -65,9 +64,9 @@ func (r *JsonRpc2Client) getRaw(command string, args interface{}) (string, error
|
||||
log.Info("request = ", string(fullCommandBytes))
|
||||
|
||||
_, err = r.conn.Write([]byte(string(fullCommandBytes) + "\n"))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
connbuf := bufio.NewReader(r.conn)
|
||||
for {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"errors"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type ConfigEntry struct {
|
||||
TcpPort int64 `yaml:"tcp_port"`
|
||||
TcpPort int64 `yaml:"tcp_port"`
|
||||
FifoPathname string `yaml:"fifo_pathname"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Entries map[string]ConfigEntry `yaml:"config,omitempty"`
|
||||
Entries map[string]ConfigEntry `yaml:"config,omitempty"`
|
||||
}
|
||||
|
||||
type JsonRpc2ClientConfig struct {
|
||||
@@ -20,8 +20,7 @@ type JsonRpc2ClientConfig struct {
|
||||
}
|
||||
|
||||
func NewJsonRpc2ClientConfig() *JsonRpc2ClientConfig {
|
||||
return &JsonRpc2ClientConfig{
|
||||
}
|
||||
return &JsonRpc2ClientConfig{}
|
||||
}
|
||||
|
||||
func (c *JsonRpc2ClientConfig) Load(path string) error {
|
||||
@@ -43,7 +42,7 @@ func (c *JsonRpc2ClientConfig) GetTcpPortForNumber(number string) (int64, error)
|
||||
return val.TcpPort, nil
|
||||
}
|
||||
|
||||
return 0, errors.New("No number found")
|
||||
return 0, errors.New("Number " + number + " not found in local map")
|
||||
}
|
||||
|
||||
func (c *JsonRpc2ClientConfig) GetFifoPathnameForNumber(number string) (string, error) {
|
||||
@@ -51,7 +50,7 @@ func (c *JsonRpc2ClientConfig) GetFifoPathnameForNumber(number string) (string,
|
||||
return val.FifoPathname, nil
|
||||
}
|
||||
|
||||
return "", errors.New("No number found")
|
||||
return "", errors.New("Number " + number + " not found in local map")
|
||||
}
|
||||
|
||||
func (c *JsonRpc2ClientConfig) GetTcpPortsForNumbers() map[string]int64 {
|
||||
|
||||
Reference in New Issue
Block a user