Documentation ¶
Overview ¶
Package echo contains utilities to inspect HTTP requests.
Index ¶
- Constants
- Variables
- func Echo(w http.ResponseWriter, r *http.Request)
- func PolicyFromEnv() func(*EnvVar) bool
- func VeryDangerousAllowAll(_ *EnvVar) bool
- type Body
- type Color
- type ColorPalette
- type EchoHandler
- type EnvVar
- type EnvironmentDump
- type EnvironmentDumpPolicy
- type Header
- type RGBAColor
- type RequestDump
Constants ¶
const FullOpacity uint8 = 100
Variables ¶
var ( // DefaultColors for the rendering of the UI. DefaultColors = ColorPalette{ &RGBAColor{9, 94, 147, FullOpacity}, &RGBAColor{102, 157, 13, FullOpacity}, &RGBAColor{243, 0, 8, FullOpacity}, &RGBAColor{221, 162, 0, FullOpacity}, &RGBAColor{71, 25, 134, FullOpacity}, } )
Functions ¶
func Echo ¶
func Echo(w http.ResponseWriter, r *http.Request)
Echo the request back to the client as plain text.
func PolicyFromEnv ¶
PolicyFromEnv is an EnvironmentDumpPolicy which reads the value of the ECHO_VARS environment variable, and allows dumping any env var names found. If the value is set to "..." then the entire environment is dumped (which is often a bad idea).
func VeryDangerousAllowAll ¶
VeryDangerousAllowAll is an EnvironmentDumpPolicy which dumps the entire environment. Aim this away from your foot before using.
Types ¶
type Body ¶
type Body struct { // Content of the HTTP body, represented as bytes. Content []byte // AllegedType of the content, as reported by the client. No validation is // done on this value, so be sure you trust the client before relying on it. AllegedType string }
Body of an HTTP payload.
type EchoHandler ¶
EchoHandler renders HTML payloads containing the in-bound request along with some details about the running environment of the server.
func (*EchoHandler) ServeHTTP ¶
func (h *EchoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type EnvVar ¶
type EnvVar struct {
Name, Value string
}
EnvVar is an environment variable value stored in memory as a name / value pair.
type EnvironmentDump ¶
type EnvironmentDump struct {
Variables []*EnvVar
}
EnvironmentDump represents the bits of the running environment to be dumped for return in a response payload.
func DumpEnv ¶
func DumpEnv(policy EnvironmentDumpPolicy) *EnvironmentDump
DumpEnv for rendering in an HTML payload.
type EnvironmentDumpPolicy ¶
EnvironmentDumpPolicy determines what should be dumped from the running process' environment.
type Header ¶
type Header struct { Name string `json:"name"` Value string `json:"value,omitempty"` Index int `json:"index"` Count int `json:"repeat_count"` }
Header of an HTTP request.
func DumpHeader ¶
DumpeHeader from an HTTP request.
type RGBAColor ¶
type RGBAColor struct {
// R, G, and B color values between 0 and 255.
R, G, B uint8
// Alpha value out of 100. Values higher than 100 will be rounded down.
Alpha uint8
}
RGBAColor implements Color for the RGBA color space.
type RequestDump ¶
type RequestDump struct { Requestor string `json:"requestor"` Method string `json:"method"` Target string `json:"target"` Proto string `json:"protocol"` Headers []*Header `json:"headers"` Body Body `json:"-"` }
RequestDump is a renderable dump of an inbound HTTP request.
func DumpRequest ¶
func DumpRequest(req *http.Request) *RequestDump
DumpRequest for rendering in an HTML payload.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
echoserver
Program echoserver is an HTTP server which accepts any request and responds with with 200 OK.
|
Program echoserver is an HTTP server which accepts any request and responds with with 200 OK. |