summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--post.go29
1 files changed, 29 insertions, 0 deletions
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")