add a specific http POST option
This commit is contained in:
parent
22ebf174c8
commit
eaadfa21d3
29
http.go
29
http.go
|
@ -9,9 +9,38 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
|
||||||
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
"go.wit.com/log"
|
"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) {
|
func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) {
|
||||||
var err error
|
var err error
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
|
|
Loading…
Reference in New Issue