httplog

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 5 Imported by: 0

README

httplog

httplog is a command line tool that launches a local HTTP server that logs all requests it receives, replying with a canned response.

screenshot of httplog

Install

Either download a pre-built binary, or install from source (requires Go 1.19+):

go install github.com/jamescun/httplog

Usage

httplog v1.0.0

httplog is a command line tool that launches a local HTTP server that logs all
requests it receives, replying with a canned response.

Usage: httplog [options...]

Options:
  --help                        show helpful information
  --listen         <host:port>  configure the listening address for the HTTP
                                server (default localhost:8080)
  --response       <text>       configure the canned body sent in response to
                                all requests (default none)
  --response-code  <code>       configure the HTTP status code sent in response
                                to all requests (default 200)
  --json                        log all requests as JSON rather than human
                                readable text

### Examples

Run with no options, a server will be launched on localhost:8080, answering no body and an HTTP 200 status code to all requests.

To configure the HTTP status code, use the --response-code <code> option, i.e. for a HTTP 500 Internal Server code:

$ httplog --response-code 500

$ curl -v http://localhost:8080
HTTP/1.1 500 Internal Server Error

To configure the response body, use the --response <text> option, i.e. to response the text hello world to all requests:

$ httplog --response "hello world"

$ curl http://localhost:8080
Hello World

If you would prefer JSON output, rather than human-readable text, use the --json option.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL