writer

package
v0.0.0-...-c265b2b Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package writer provides convenience wrappers around common write/print operations for our HTTP primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrintOpt

type PrintOpt func(*printOpts)

A PrintOpt is an option for printing an HTTP request or response.

func WithBody

func WithBody(b bool) PrintOpt

WithBody specifies that the response body should be printed.

func WithHeaders

func WithHeaders(b bool) PrintOpt

WithHeaders specifies that the response headers should be printed.

func WithHighlight

func WithHighlight(b bool) PrintOpt

WithHighlight specifies that the request/response body should be highlighted.

func WithStream

func WithStream(b bool) PrintOpt

WithStream specifies that the response body should be streamed.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

A Writer wraps an io.Writer and provides convenience methods for writing data.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer that wraps w.

func (*Writer) PrintRequest

func (w *Writer) PrintRequest(req *http.Request, opts ...PrintOpt) error

PrintRequest prints information about an HTTP request.

func (*Writer) PrintResponse

func (w *Writer) PrintResponse(resp *http.Response, opts ...PrintOpt) error

PrintResponse prints information about an HTTP response.

func (*Writer) Printf

func (w *Writer) Printf(format string, a ...any) error

Printf writes a formatted string to the underlying io.Writer.

func (*Writer) PrintfBlue

func (w *Writer) PrintfBlue(format string, a ...any) error

PrintfBlue writes a formatted string to the underlying io.Writer in blue.

func (*Writer) PrintfCyan

func (w *Writer) PrintfCyan(format string, a ...any) error

PrintfCyan writes a formatted string to the underlying io.Writer in red.

func (*Writer) PrintfGreen

func (w *Writer) PrintfGreen(format string, a ...any) error

PrintfGreen writes a formatted string to the underlying io.Writer in green.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

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