AppendHeaders

This commit is contained in:
2023-10-28 21:48:54 +01:00
parent e74c3a684e
commit c5fef8e42d
5 changed files with 20 additions and 7 deletions

View File

@@ -2,22 +2,33 @@ package config
import (
"fmt"
"net/http"
"os/exec"
"strings"
)
type Command struct {
Program string
Arguments []string
AppendPayload bool
AppendHeaders bool
}
func (c Command) Execute(payload string) ([]byte, error) {
func (c Command) Execute(payload string, header http.Header) ([]byte, error) {
arguments := make([]string, 0)
copy(c.Arguments, arguments)
if c.AppendPayload {
arguments = append(arguments, payload)
}
if c.AppendHeaders {
var header_builder strings.Builder;
header.Write(&header_builder);
arguments = append(arguments, header_builder.String())
}
return exec.Command(c.Program, arguments...).Output()
}