@@ -21,6 +21,7 @@ import (
2121 "net/http"
2222 "strings"
2323
24+ "github.com/google/uuid"
2425 "moul.io/http2curl"
2526
2627 "github.com/adh-partnership/api/pkg/logger"
@@ -42,9 +43,11 @@ func Handle(method, url, contenttype, body string) (int, []byte, error) {
4243// HandleWithHeaders will make the request as presented in a structured and expected way. It adds appropriate headers, including
4344// a user agent so our requests can be known to come from us.
4445func HandleWithHeaders (method , url , contenttype , body string , headers map [string ]string ) (int , []byte , error ) {
46+ request_id , _ := uuid .NewV7 ()
47+
4548 r , err := http .NewRequest (method , url , strings .NewReader (body ))
46- log .Debugf ( " Making request: %s %s" , method , url )
47- log .Debugf ( "with Body: %s" , body )
49+ log .Infof ( "Request %s - Making request: %s %s", request_id , method , url )
50+ log .Infof ( "Request %s - With Body: %s", request_id , body )
4851 if err != nil {
4952 return 0 , nil , err
5053 }
@@ -56,7 +59,7 @@ func HandleWithHeaders(method, url, contenttype, body string, headers map[string
5659 }
5760
5861 curl , _ := http2curl .GetCurlCommand (r )
59- log .Debugf ("Request curl equivalent: %s" , curl )
62+ log .Debugf ("Request %s - Request curl equivalent: %s" , request_id , curl )
6063
6164 client := & http.Client {}
6265 resp , err := client .Do (r )
@@ -73,8 +76,8 @@ func HandleWithHeaders(method, url, contenttype, body string, headers map[string
7376 return 0 , nil , err
7477 }
7578
76- log .Debugf ( " Response from %s %s: %d" , method , url , resp .StatusCode )
77- log .Tracef ("Response body: %s" , string (contents ))
79+ log .Infof ( "Request %s - Response from %s %s: %d", request_id , method , url , resp .StatusCode )
80+ log .Tracef ("Request %s - Response body: %s" , request_id , string (contents ))
7881
7982 return resp .StatusCode , contents , nil
8083}
0 commit comments