timeout

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) gin.HandlerFunc

New wraps a handler and aborts the process of the handler if the timeout is reached

Types

type Option

type Option func(*Timeout)

Option for timeout

func WithHandler

func WithHandler(h gin.HandlerFunc) Option

WithHandler add gin handler

func WithResponse

func WithResponse(h gin.HandlerFunc) Option

WithResponse add gin handler

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout set timeout

type Timeout

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

Timeout struct

type Writer

type Writer struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

Writer is a writer with memory buffer

func NewWriter

func NewWriter(w gin.ResponseWriter, buf *bytes.Buffer) *Writer

NewWriter will return a timeout.Writer pointer

func (*Writer) FreeBuffer

func (w *Writer) FreeBuffer()

FreeBuffer will release buffer pointer

func (*Writer) Header

func (w *Writer) Header() http.Header

Header will get response headers

func (*Writer) Write

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

Write will write data to response body

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(code int)

WriteHeader will write http status code

func (*Writer) WriteString

func (w *Writer) WriteString(s string) (int, error)

WriteString will write string to response body

Jump to

Keyboard shortcuts

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