used this to fix autogenpb 'http' functions

This commit is contained in:
Jeff Carr 2025-09-09 19:15:31 -05:00
parent 1c479b61f6
commit d656828a0f
2 changed files with 9 additions and 11 deletions

16
http.go
View File

@ -37,10 +37,10 @@ func (m *Machine) HttpPostMachine(url string) ([]byte, error) {
log.Info("WTF. check == nil")
}
// log.Info("good? check.hostname =", m.Hostname)
return m.HttpPost(url, msg)
return m.HttpPostOld(url, msg)
}
func (m *Machine) HttpPost(url string, data []byte) ([]byte, error) {
func (m *Machine) HttpPostOld(url string, data []byte) ([]byte, error) {
var err error
var req *http.Request
@ -49,13 +49,11 @@ func (m *Machine) HttpPost(url string, data []byte) ([]byte, error) {
usr, _ := user.Current()
req.Header.Set("author", usr.Username)
/*
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 == nil {
// // run f.InitMachine() here?
// log.Info("you must run f.InitMachine()")
// return nil, fmt.Errorf("you must run f.InitMachine()")
// }
req.Header.Set("hostname", m.Hostname)
client := &http.Client{}

View File

@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time
// global settings for autogenpb `autogenpb:mutex`
message Machine { // `autogenpb:marshal`
message Machine { // `autogenpb:marshal` `autogenpb:http`
string hostname = 1; // `autogenpb:unique` `autogenpb:sort`
int64 memory = 2;
int64 cpus = 3;
@ -23,7 +23,7 @@ message Machine { // `autogenpb:marshal`
string upgradeCmd = 13; // upgrade cmd
}
message Machines { // `autogenpb:marshal` `autogenpb:gui`
message Machines { // `autogenpb:marshal` `autogenpb:gui` `autogenpb:http`
string uuid = 1; // `autogenpb:uuid:b57e7fac-a8fc-4949-9d50-fa38312dec87`
string version = 2; // `autogenpb:version:v0.0.1`
repeated Machine machines = 3;