caddy-respond - Man Page

Simple, hard-coded HTTP responses for development and testing

Synopsis

caddy respond [--status ] [--body ] [--listen ] [--access-log] [--debug] [--header "Field: value"]  [flags]

Description

Spins up a quick-and-clean HTTP server for development and testing purposes.

With no options specified, this command listens on a random available port and answers HTTP requests with an empty 200 response. The listen address can be customized with the --listen flag and will always be printed to stdout. If the listen address includes a port range, multiple servers will be started.

If a final, unnamed argument is given, it will be treated as a status code (same as the --status flag) if it is a 3-digit number. Otherwise, it is used as the response body (same as the --body flag). The --status and --body flags will always override this argument (for example, to write a body that literally says "404" but with a status code of 200, do '--status 200 404').

A body may be given in 3 ways: a flag, a final (and unnamed) argument to the command, or piped to stdin (if flag and argument are unset). Limited template evaluation is supported on the body, with the following variables:

{{.N}}        The server number (useful if using a port range)
{{.Port}}     The listener port
{{.Address}}  The listener address

(See the docs for the text/template package in the Go standard library for information about using templates: https://pkg.go.dev/text/template)

Access/request logging and more verbose debug logging can also be enabled.

Response headers may be added using the --header flag for each header field.

Options

--access-log[=false] Enable the access log

-b, --body="" The body of the HTTP response

-v, --debug[=false] Enable more verbose debug-level logging

-H, --header=[] Set a header on the response (format: "Field: value")

-h, --help[=false] help for respond

-l, --listen=":0" The address to which to bind the listener

-s, --status=200 The response status code

See Also

caddy(8)

History

5-Jul-2024 Auto generated by spf13/cobra

Referenced By

caddy(8).

Jul 2024 Auto generated by spf13/cobra