From 0e01e83a751c67f728aa5725175c03a709faf450 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 20 Oct 2025 13:21:31 -0500 Subject: notsure if this is already in the code --- post.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/post.go b/post.go index f18de27..58c36f4 100644 --- a/post.go +++ b/post.go @@ -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") -- cgit v1.2.3