testing routine
This commit is contained in:
@@ -2,6 +2,7 @@ package netproto
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type MainHeader struct {
|
||||
@@ -121,6 +122,18 @@ func DecodeBase64(input string) (string, error) {
|
||||
return string(d), nil
|
||||
}
|
||||
|
||||
func ToJSON(input interface{}) (string, error) {
|
||||
b, err := json.Marshal(input)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
|
||||
func FromJSON(input string, output interface{}) error {
|
||||
return json.Unmarshal([]byte(input), output)
|
||||
}
|
||||
|
||||
type ExtensionHeader struct {
|
||||
Type uint8 `json:"type"`
|
||||
Meta map[string]string `json:"meta"`
|
||||
|
Reference in New Issue
Block a user