https://github.com/1602/witness
https://github.com/1602/witness
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/1602/witness
- Owner: 1602
- License: apache-2.0
- Created: 2019-03-25T19:58:01.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-03-12T22:19:34.000Z (over 2 years ago)
- Last Synced: 2025-01-26T18:11:29.488Z (over 1 year ago)
- Language: Go
- Size: 86.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/1602/witness)
[](https://travis-ci.org/1602/witness)
[](https://coveralls.io/github/1602/witness?branch=main)
## Witness
Enables debugging of http requests via UI. It is like chrome devtools for go backend.
## How it works
It uses `httptrace.WithClientTrace` to make a `http.RoundTripper` eavesdropping on http connection. This allows detailed analysis of various http request stages. All information gathered then pushed using EventStream to UI running in browser.
## Usage
The idea is to observe http client you want to debug by calling `witness.DebugClient` with the http client in question. For example, if you "own" a client to make http calls to some API:
```
// init http client with any configuration you need
cl := &http.Client{}
// pass client to witness to wrap its Transport with eavesdropping functionality
// it will also start SSE notification channel
witness.DebugClient(cl)
// then use cl as http client for making request
```
Alternatively, is you are interested in behaviour of some third-party http client, k8s client for example, you could eavesdrop on http client created by k8s go client code.
TODO: make demo of k8s client eavesdropping