26 lines
526 B
Go
26 lines
526 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"go-rest-cctweaked/networking"
|
|
"strconv"
|
|
)
|
|
|
|
func processSend(args []string) {
|
|
if len(args) < 4 {
|
|
gracefullExit("Send take additional url, content and type arguments. Check --help")
|
|
}
|
|
url := args[1]
|
|
content := args[2]
|
|
msgType, err := strconv.Atoi(args[3])
|
|
if err != nil {
|
|
panic("Failed converting message type to integer.")
|
|
}
|
|
|
|
json := networking.EncodeJson(content, msgType)
|
|
|
|
statusCode := networking.PostJsonBody(url, json)
|
|
|
|
fmt.Printf("Server responded with: %v\n", statusCode)
|
|
}
|