feat: support websocket protocol

This commit is contained in:
buyuxiang
2022-04-21 20:53:11 +08:00
parent f7f0c5d2cf
commit 3588ab0f0a
18 changed files with 1205 additions and 36 deletions

View File

@@ -16,6 +16,7 @@ var Functions = map[string]interface{}{
"md5": MD5, // call with one argument
"parameterize": loadFromCSV,
"P": loadFromCSV,
"load_ws_message": loadMessage,
}
func init() {

View File

@@ -282,6 +282,16 @@ func loadFromCSV(path string) []map[string]interface{} {
return result
}
func loadMessage(path string) []byte {
log.Info().Str("path", path).Msg("load message file")
file, err := readFile(path)
if err != nil {
log.Error().Err(err).Msg("read message file failed")
os.Exit(1)
}
return file
}
func readFile(path string) ([]byte, error) {
var err error
path, err = filepath.Abs(path)