Add initial UI/UX for intecepting requests

This commit is contained in:
David Stotijn
2022-03-10 20:30:40 +01:00
parent 71e550f0cd
commit 9dd8464af7
24 changed files with 882 additions and 203 deletions

View File

@ -176,6 +176,19 @@ func (svc *Service) Requests() []*http.Request {
return reqs
}
// Request returns an intercepted request by ID. It's safe for concurrent use.
func (svc *Service) RequestByID(id ulid.ULID) (*http.Request, error) {
svc.mu.RLock()
defer svc.mu.RUnlock()
req, ok := svc.requests[id]
if !ok {
return nil, ErrRequestNotFound
}
return req.req, nil
}
func (ids RequestIDs) Len() int {
return len(ids)
}