{"repo":"henvic/httpretty","free":true,"listed":false,"github":"https://github.com/henvic/httpretty","clone":"git clone https://github.com/henvic/httpretty.git","description":"Package httpretty prints the HTTP requests you make with Go pretty on your terminal.","language":"Go","stars":450,"topics":["go","golang","cli","http"],"license":"MIT","category":"cli-tools","readme_excerpt":"httpretty Package httpretty prints the HTTP requests of your Go programs pretty on your terminal screen. It is mostly inspired in curl's --verbose mode, and also on the httputil.DumpRequest and similar functions. Setting up a logger You can define a logger with something like This code will set up a logger with sane settings. By default the logger prints nothing but the request line (and the remote address, when using it on the server-side). Using on the client-side You can set the transport for the net/http.Client you are using like this: If you don't care about setting a new client, you can safely replace your existing http.DefaultClient with this: Then httpretty is going to print information about regular requests to your terminal when code such as this is called: However, have in mind you usually want to use a custom http.Client to control things such as timeout. Logging on the server-side You can use the logger quickly to log requests on your server. For example: The handler should by a http.Handler. Usually, you want this to be your http.ServeMux HTTP entrypoint. For working examples, please see the example directory. Filtering You have two ways to filter a request so it isn't printed by the logger. httpretty.WithHide You can filter any request by setting a request context before the request reaches httpretty.RoundTripper : Filter function A second option is to implement and set it as the filter for your logger. For example: Formatters You can define a formatter for any","default_branch":null,"files":null,"tree":[],"storefront":"/r/henvic","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/henvic/httpretty/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}