util

package
v1.1.0-beta.0...-2ea7d98 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReaderSize = 16 * 1024

DefaultReaderSize is the default size of bufio.Reader.

Variables

This section is empty.

Functions

func LengthEncodedIntSize

func LengthEncodedIntSize(n uint64) int

LengthEncodedIntSize returns the size of length encoded integer.

func NewCorsHandler

func NewCorsHandler(handler http.Handler, cfg *config.Config) http.Handler

NewCorsHandler creates a new CorsHandler.

func NewTestConfig

func NewTestConfig() *config.Config

NewTestConfig creates a new config for test.

func ParseLengthEncodedBytes

func ParseLengthEncodedBytes(b []byte) ([]byte, bool, int, error)

ParseLengthEncodedBytes parses a length encoded byte slice.

func ParseLengthEncodedInt

func ParseLengthEncodedInt(b []byte) (num uint64, isNull bool, n int, err error)

ParseLengthEncodedInt parses a length encoded integer. It returns io.EOF when the length-encoded header is truncated.

func ParseNullTermString

func ParseNullTermString(b []byte) (str []byte, remain []byte)

ParseNullTermString parses a null terminated string.

Types

type BufferedReadConn

type BufferedReadConn struct {
	net.Conn
	// contains filtered or unexported fields
}

BufferedReadConn is a net.Conn compatible structure that reads from bufio.Reader.

func NewBufferedReadConn

func NewBufferedReadConn(conn net.Conn) *BufferedReadConn

NewBufferedReadConn creates a BufferedReadConn.

func (BufferedReadConn) IsAlive

func (conn BufferedReadConn) IsAlive() int

IsAlive detects the connection is alive or not. return value < 0, means unknow return value = 0, means not alive return value = 1, means still alive

func (BufferedReadConn) Peek

func (conn BufferedReadConn) Peek(n int) ([]byte, error)

Peek peeks from the connection.

func (BufferedReadConn) Read

func (conn BufferedReadConn) Read(b []byte) (n int, err error)

Read reads data from the connection.

type CorsHandler

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

CorsHandler adds Cors Header if `cors` config is set.

func (CorsHandler) ServeHTTP

func (h CorsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler interface.

type InputDecoder

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

InputDecoder is used to decode input.

func NewInputDecoder

func NewInputDecoder(chs string) *InputDecoder

NewInputDecoder creates a new InputDecoder.

func (*InputDecoder) DecodeInput

func (i *InputDecoder) DecodeInput(src []byte) []byte

DecodeInput decodes input.

Jump to

Keyboard shortcuts

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