Documentation
¶
Index ¶
- Constants
- Variables
- func GetBodyLimit(body io.Reader, contentLength, n int64) ([]byte, error)
- func GetLogFields() logrus.Fields
- func GetLogger(c *gin.Context) *logrus.Entry
- func GetRequestBody(req *http.Request) ([]byte, error)
- func GetRequestBodyLimit(req *http.Request, n int64) ([]byte, error)
- func GetRequestBodyReusable(req *http.Request) ([]byte, error)
- func GetResponseBody(resp *http.Response) ([]byte, error)
- func GetResponseBodyLimit(resp *http.Response, n int64) ([]byte, error)
- func InitRedisClient() (err error)
- func LimitReader(r io.Reader, n int64) io.Reader
- func NeedColor() bool
- func NewLogger() *logrus.Entry
- func PutLogFields(fields logrus.Fields)
- func RedisKey(keys ...string) string
- func RedisKeyPrefix() string
- func RedisKeyf(format string, args ...any) string
- func SetRequestBody(req *http.Request, body []byte)
- func ShortUUID() string
- func TruncateByRune[T ~string](s T, length int) T
- func TruncateBytesByRune(b []byte, length int) []byte
- func UnmarshalRequest2NodeReusable(req *http.Request, path ...any) (ast.Node, error)
- func UnmarshalRequestReusable(req *http.Request, v any) error
- func UnmarshalResponse(resp *http.Response, v any) error
- func UnmarshalResponse2Node(resp *http.Response, path ...any) (ast.Node, error)
- type LimitedReader
- type RequestBodyKey
Constants ¶
View Source
const ( MaxRequestBodySize = 1024 * 1024 * 50 // 50MB MaxResponseBodySize = 1024 * 1024 * 50 // 50MB )
Variables ¶
View Source
var ( UsingSQLite = false UsingPostgreSQL = false UsingMySQL = false )
View Source
var ( SQLitePath = env.String("SQLITE_PATH", "aiproxy.db") SQLiteBusyTimeout = env.Int64("SQLITE_BUSY_TIMEOUT", 3000) )
View Source
var ( RDB *redis.Client RedisEnabled = false )
View Source
var ErrLimitedReaderExceeded = errors.New("limited reader exceeded")
View Source
var StartTime = time.Now().UnixMilli() // unit: millisecond
Functions ¶
func GetLogFields ¶
func InitRedisClient ¶
func InitRedisClient() (err error)
InitRedisClient This function is called after init()
func PutLogFields ¶
func RedisKeyPrefix ¶
func RedisKeyPrefix() string
func SetRequestBody ¶
func TruncateByRune ¶
func TruncateBytesByRune ¶
Types ¶
type LimitedReader ¶
type RequestBodyKey ¶
type RequestBodyKey struct{}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.