Skip to content

Instantly share code, notes, and snippets.

@JonCooperWorks
Created October 5, 2020 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonCooperWorks/c8dd47dcaa4957a19e2e0ac6e5ba600e to your computer and use it in GitHub Desktop.
Save JonCooperWorks/c8dd47dcaa4957a19e2e0ac6e5ba600e to your computer and use it in GitHub Desktop.
// InitializerFunc is a go function that should be exported by a function package.
// It should be named "New".
// Your InitializerFunc should return an instance of your Listener with a reference to judas's logger for consistent logging.
type InitializerFunc func(*log.Logger) (Listener, error)
// Listener implementations will be given a stream of HTTPExchanges to let plugins capture valuable information out of request-response transactions.
type Listener interface {
Listen(<-chan *HTTPExchange)
}
// HTTPExchange contains the request sent by the user to us and the response received from the target server.
// Listeners can use this struct to pull information out of requests and responses.
type HTTPExchange struct {
Request *Request
Response *Response
Target *url.URL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment