| 175 | } |
| 176 | |
| 177 | func encodeRequest(req *HTTPRequest) map[string]any { |
| 178 | headers := make(map[string]any, len(req.Headers)) |
| 179 | for key, values := range req.Headers { |
| 180 | copyValues := make([]string, len(values)) |
| 181 | copy(copyValues, values) |
| 182 | headers[key] = copyValues |
| 183 | } |
| 184 | return map[string]any{ |
| 185 | "method": req.Method, |
| 186 | "url": req.URL, |
| 187 | "headers": headers, |
| 188 | "body": string(req.Body), |
| 189 | "sent_at": time.Now().UTC().Format(time.RFC3339Nano), |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | func decodeResponse(payload map[string]any) *HTTPResponse { |
| 194 | if payload == nil { |