diff --git a/capture.go b/capture.go index 24a48fa..3653b37 100644 --- a/capture.go +++ b/capture.go @@ -3,6 +3,7 @@ package main import "strconv" type Capture struct { + ID int `json:"id"` Path string `json:"path"` Method string `json:"method"` Status int `json:"status"` @@ -32,7 +33,7 @@ func (items *Captures) ToReferences(itemBaseUrl string) []CaptureRef { refs := make([]CaptureRef, len(*items)) for i, item := range *items { refs[i] = CaptureRef{ - ID: i, + ID: item.ID, Path: item.Path, Method: item.Method, Status: item.Status, diff --git a/main.go b/main.go index 3346be1..7046407 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ type Transport struct { http.RoundTripper } +var captureID = 0 var captures Captures var socket socketio.Socket @@ -101,12 +102,14 @@ func (t Transport) RoundTrip(req *http.Request) (*http.Response, error) { } capture := Capture{ + ID: captureID, Path: req.URL.Path, Method: req.Method, Status: res.StatusCode, Request: string(reqDump), Response: string(resDump), } + captureID++ captures.Add(capture) emit()