diff options
| author | Jeff Carr <[email protected]> | 2025-10-20 13:21:31 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-20 13:21:31 -0500 | 
| commit | 0e01e83a751c67f728aa5725175c03a709faf450 (patch) | |
| tree | f5c628edb445ab96b2632bddc1cbf294723ca19a | |
| parent | 13e3ff7beeda79783dec0ebb682982283c6fa611 (diff) | |
| -rw-r--r-- | post.go | 29 | 
1 files changed, 29 insertions, 0 deletions
@@ -62,6 +62,35 @@ func DoPost(baseURL string, route string, data []byte) (*HttpRequest, error) {  	return reqPB, nil  } +/* +// HTTPRequestToProto converts an *http.Request to our custom HttpRequest protobuf message. +func (pb *Patches) AddHttpToPB(r *http.Request) error { +	if pb == nil { +		return log.Errorf("AddHttpToPB() pb was nil") +	} +	// Convert the header map. http.Header is a map[string][]string. +	// We'll just take the first value for each header for simplicity. +	headers := make(map[string]string) +	for name, values := range r.Header { +		if len(values) > 0 { +			headers[name] = strings.Join(values, "\n") +		} +	} + +	pb.HttpRequest = &httppb.HttpRequest{ +		Method:   r.Method, +		URL:      r.URL.String(), +		Proto:    r.Proto, +		Headers:  headers, +		IP:       getClientIP(r), +		Host:     r.Host, +		Hostname: r.Header.Get("hostname"), +	} +	// pb.HttpRequest.Route = cleanURL(r.URL.Path) +	return nil +} +*/ +  func HttpPost(baseURL string, route string, data []byte) ([]byte, error) {  	// Fix using url.JoinPath (Best Practice)  	tmpURL, _ := url.Parse(baseURL)    // "http://forge.grid.wit.com:2520")  | 
