Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1602/witness
https://github.com/1602/witness
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/1602/witness
- Owner: 1602
- License: apache-2.0
- Created: 2019-03-25T19:58:01.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-12T22:19:34.000Z (8 months ago)
- Last Synced: 2024-06-21T00:07:30.826Z (5 months 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
[![Go Report Card](https://goreportcard.com/badge/github.com/1602/witness)](https://goreportcard.com/report/github.com/1602/witness)
[![Build Status](https://travis-ci.org/1602/witness.svg?branch=main)](https://travis-ci.org/1602/witness)
[![Coverage Status](https://img.shields.io/coveralls/github/1602/witness.svg)](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