gindump

package module
v0.0.0-...-cc93b9e Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 9 Imported by: 0

README

Gin-Dump

  • Gin Middleware
  • Dump HTTP Request and Response

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(maxReqRespSize int) gin.HandlerFunc

Types

type DumpRequest

type DumpRequest struct {
	Method string
	URL    *url.URL
	Proto  string
	Header http.Header
	Body   io.ReadCloser
}

func GetRequest

func GetRequest(c *gin.Context) (*DumpRequest, error)

type DumpResponse

type DumpResponse struct {
	StatusCode int
	Header     http.Header
	Body       io.ReadCloser
}

func GetResponse

func GetResponse(c *gin.Context) (*DumpResponse, error)

type LimitedBuffer

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

LimitedBuffer is a wrapper of bytes.Buffer which limits its size. The buffer will store no more than the specified size, and discards the rest. This is useful for preventing gindump from storing large request/response body in memory. LimitedBuffer implements Writer and Reader interface.

func NewLimitedBuffer

func NewLimitedBuffer(size int) *LimitedBuffer

Create a new LimitedBuffer with a limited size in bytes.

func (*LimitedBuffer) Bytes

func (lb *LimitedBuffer) Bytes() []byte

Bytes returns the bytes of the underlying buffer.

func (*LimitedBuffer) Read

func (lb *LimitedBuffer) Read(p []byte) (n int, err error)

Read implements the io.Reader interface.

func (*LimitedBuffer) Write

func (lb *LimitedBuffer) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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