speakhttp

package
v0.0.0-...-8371aea Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package speakhttp provides methods of pretty printing http packets

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestWellKnownHeaders = []string{
		"Host",
		"Date",
		"User-Agent",
		"Accept",
		"Connection",
		"Authorization",
		"Accept-Charset",
		"Accept-Encoding",
		"Accept-Language",
		"Cookie",
		"Content-Length",
		"Referer",
		"Upgrade",
	}
	ResponseWellKnownHeaders = []string{
		"Server",
		"Date",
		"Last-Modified",
		"Connection",
		"Content-Type",
		"Content-Length",
		"Transfer-Encoding",
		"Status",
		"Cache-Control",
		"Set-Cookie",
		"Trailer",
		"Vary",
	}
)

refer to https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Functions

func ColorRequest

func ColorRequest(req *http.Request)

ColorRequest is the print function for http request in colored style without body

func ColorRequestWithBody

func ColorRequestWithBody(req *http.Request)

ColorRequestWithBody is the print function for http request in colored style with body

func ColorResponse

func ColorResponse(res *http.Response)

ColorResponse is the print function for http response in colored style without body

func ColorResponseWithBody

func ColorResponseWithBody(res *http.Response)

ColorResponseWithBody is the print function for http response in colored style with body

func CurlRequest

func CurlRequest(req *http.Request)

CurlRequest is the print function for http response in curl style without body

func CurlRequestWithBody

func CurlRequestWithBody(req *http.Request)

CurlRequestWithBody is the print function for http response in curl style with body content

func CurlResponse

func CurlResponse(res *http.Response)

CurlResponse is the print function for http response in curl style without body

func CurlResponseWithBody

func CurlResponseWithBody(res *http.Response)

CurlResponseWithBody is the print function for http response in curl style with body content

Types

type Render

type Render interface {
	// SpeakRequest is the method to printing http request
	SpeakRequest(*http.Request)
	// SpeakResponse is the method of printing http response
	SpeakResponse(*http.Response)
}

Render defines the type of printing http request and response packets

func NewRender

func NewRender(sReq func(*http.Request), sRes func(*http.Response)) Render

NewRender is the factory function to return a Render interface You can specify your own print request and response functions

Jump to

Keyboard shortcuts

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