utils

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPAccessLogLevel = zerolog.InfoLevel

Variables

View Source
var HeaderCache = sync.Pool{
	New: func() any {
		return map[string][]byte{}
	},
}
View Source
var HeadersIgnoreList = map[string]interface{}{
	"X-Accel-Expires":    nil,
	"Expires":            nil,
	"Cache-Control":      nil,
	"Set-Cookie":         nil,
	"Vary":               nil,
	"X-Accel-Redirect":   nil,
	"X-Accel-Limit-Rate": nil,
	"X-Accel-Buffering":  nil,
	"X-Accel-Charset":    nil,
}

Functions

func AcquireHeaderCache added in v1.0.15

func AcquireHeaderCache() map[string][]byte

func ReleaseApiResponse added in v1.0.8

func ReleaseApiResponse(ar *ApiResponse)

func ReleaseApiResponseWOData added in v1.0.8

func ReleaseApiResponseWOData(ar *ApiResponseWOData)

func ReleaseHeaderCache added in v1.0.15

func ReleaseHeaderCache(hcache map[string][]byte)

func RespondPlainWithStatus

func RespondPlainWithStatus(c *fiber.Ctx, status int) error

func RespondWithApiError added in v1.0.6

func RespondWithApiError(status int, msg, desc string, w io.Writer) (e error)

func RespondWithRandomRelease added in v1.0.10

func RespondWithRandomRelease(code string, w io.Writer) (e error)

func SetUpSyslogWriter

func SetUpSyslogWriter(c *cli.Context) (_ io.Writer, e error)

Types

type ApiError added in v1.0.6

type ApiError struct {
	Code        int
	Message     string
	Description string
}

func (ApiError) MarshalEasyJSON added in v1.0.6

func (v ApiError) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApiError) MarshalJSON added in v1.0.6

func (v ApiError) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApiError) UnmarshalEasyJSON added in v1.0.6

func (v *ApiError) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApiError) UnmarshalJSON added in v1.0.6

func (v *ApiError) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ApiResponse added in v1.0.6

type ApiResponse struct {
	Status bool
	Data   *ApiResponseData
	Error  *ApiError
}

func AcquireApiResponse added in v1.0.8

func AcquireApiResponse() *ApiResponse

func (ApiResponse) MarshalEasyJSON added in v1.0.6

func (v ApiResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApiResponse) MarshalJSON added in v1.0.6

func (v ApiResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApiResponse) UnmarshalEasyJSON added in v1.0.6

func (v *ApiResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApiResponse) UnmarshalJSON added in v1.0.6

func (v *ApiResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ApiResponseData added in v1.0.10

type ApiResponseData struct {
	Code string
}

func (ApiResponseData) MarshalEasyJSON added in v1.0.10

func (v ApiResponseData) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApiResponseData) MarshalJSON added in v1.0.10

func (v ApiResponseData) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApiResponseData) UnmarshalEasyJSON added in v1.0.10

func (v *ApiResponseData) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApiResponseData) UnmarshalJSON added in v1.0.10

func (v *ApiResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ApiResponseWOData added in v1.0.8

type ApiResponseWOData struct {
	Status bool
	Data   interface{} `json:"-"`
	Error  *ApiError
}

func AcquireApiResponseWOData added in v1.0.8

func AcquireApiResponseWOData() *ApiResponseWOData

func UnmarshalApiResponse added in v1.0.6

func UnmarshalApiResponse(payload []byte) (_ *ApiResponseWOData, e error)

func (ApiResponseWOData) MarshalEasyJSON added in v1.0.8

func (v ApiResponseWOData) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ApiResponseWOData) MarshalJSON added in v1.0.8

func (v ApiResponseWOData) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ApiResponseWOData) UnmarshalEasyJSON added in v1.0.8

func (v *ApiResponseWOData) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ApiResponseWOData) UnmarshalJSON added in v1.0.8

func (v *ApiResponseWOData) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ContextKey

type ContextKey uint8
const (
	CKLogger ContextKey = iota
	CKCliCtx
	CKAbortFunc
	CKCache
	CKGeoIP
	CKRandomizer
)

type FastUserValue

type FastUserValue uint8
const (
	UVCacheKey FastUserValue = iota
)

type RequestContentType

type RequestContentType uint8
const (
	CTInvalid RequestContentType = iota
	CTApplicationUrlencoded
	CTMultipartFormData
)

Jump to

Keyboard shortcuts

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