go-rest-cctweaked/cli/SendArgument.go
2025-03-14 15:23:44 +03:00

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)
}