diff options
| author | Jeff Carr <[email protected]> | 2025-02-15 21:56:35 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-16 12:05:35 -0600 |
| commit | eaadfa21d321be69b225a3a8ecb5d16e14b78680 (patch) | |
| tree | 821b4fdd95a85d8b522448c438872249557aa70c | |
| parent | 22ebf174c81d7b2c45d283751392d58d7e41c6c4 (diff) | |
| -rw-r--r-- | http.go | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -9,9 +9,38 @@ import ( "net/http" "os/user" + "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) +func (f *Forge) HttpPostMachine(url string) ([]byte, error) { + if f.Machine == nil { + // run f.InitMachine() here? + log.Info("you must run f.InitMachine()") + return nil, fmt.Errorf("you must run f.InitMachine()") + } + if f.Machine.Hostname == "" { + log.Info("WTF. hostname is blank") + } else { + log.Info("GOOD. hostname is set to", f.Machine.Hostname) + } + log.Info("GOOD2. hostname is set to", f.Machine.Hostname) + msg, err := f.Machine.Marshal() + if err != nil { + log.Info("proto.Marshal() failed:", err) + return nil, err + } + log.Info("GOOD3. hostname is set to", f.Machine.Hostname) + + check := new(zoopb.Machine) + check.Unmarshal(msg) + if check == nil { + log.Info("WTF. check == nil") + } + log.Info("good? check.hostname =", check.Hostname) + return f.HttpPost(url, msg) +} + func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) { var err error var req *http.Request |
