Documentation
¶
Index ¶
- func Error(prefix string, err error)
- func Handler(w http.ResponseWriter, req *http.Request, next http.Handler)
- func Middleware(next http.Handler) http.Handler
- func NewRequest(ctx context.Context, method, url string, r io.Reader) (req *http.Request, recvPrefix string, err error)
- func Response(prefix string, resp *http.Response) *http.Response
- func SetLogOutput(w io.Writer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
Error logs an error message.
Currently, the only reason you'd use this would be if http.Client or http.Transport returned an error instead of a response.
func Handler ¶
Handler invokes the next http.Handler, logging both the request and the generated response.
func Middleware ¶
Middleware wraps the Handler function, turning it into http middleware.
func NewRequest ¶
func NewRequest(ctx context.Context, method, url string, r io.Reader) (req *http.Request, recvPrefix string, err error)
NewRequest is semantically equivalent to http.NewRequest. The request will be logged immediately, and if http.NewRequestWithContext returns an error, that will be logged as well.
If this function does not return an error, it will also return a prefix that can be used with the Response or Error functions.
func Response ¶
Response immediately logs the status line and headers for the response, and then replaces its Body field with a proxy object that will log the body as it's read, and then print any trailers once EOF is reached.
Types ¶
This section is empty.
Source Files
¶
- httplog.go