Documentation ¶
Index ¶
- Constants
- Variables
- func AsMaxBytesError(err error) *http.MaxBytesError
- func MaxBytesReader(r io.Reader, n int64) *maxBytesReader
- func NewSniffReadCloser(r io.ReadCloser) *sniffReadCloser
- func ParseHTTPRequest[T any](req *http.Request) (*T, error)
- func ParseHTTPRequestWithLimitedSize[T any](req *http.Request, limitedSize int64) (*T, error)
- func ParseURL(s string) (*url.URL, error)
- func WriteResponseJSON(w http.ResponseWriter, code int, obj any) error
- type File
- type FormDataRequest
- type SniffReadCloser
- type Sniffer
Constants ¶
View Source
const DefaultMaxFileSize = 100 * xbytes.MiB
View Source
const DefaultMaxInMemoryMultipartSize = 10 * xbytes.MiB // 10MiB
Variables ¶
View Source
var ( ErrHTTPBadRequest = errors.New("") ErrHTTPTooLarge = errors.New("") )
View Source
var DiscardMemory = 512 * xbytes.KiB
View Source
var MaxInMemoryMultipartSize = DefaultMaxInMemoryMultipartSize
Functions ¶
func AsMaxBytesError ¶ added in v0.5.0
func AsMaxBytesError(err error) *http.MaxBytesError
func MaxBytesReader ¶ added in v0.5.0
MaxBytesReader is similar to http.MaxBytesReader but supporting for io.Reader instead of io.ReadCloser. It also doesn't support writing to any Writer when a MaxBytesError occurs.
func NewSniffReadCloser ¶ added in v0.4.0
func NewSniffReadCloser(r io.ReadCloser) *sniffReadCloser
func ParseHTTPRequestWithLimitedSize ¶ added in v0.4.0
func WriteResponseJSON ¶
func WriteResponseJSON(w http.ResponseWriter, code int, obj any) error
Types ¶
type File ¶ added in v0.5.0
type File struct {
// contains filtered or unexported fields
}
func NewFileFromMultipartFile ¶ added in v0.5.0
func NewFileFromMultipartFile(f multipart.File, header *multipart.FileHeader) *File
func (*File) AsBytes ¶ added in v0.5.0
AsBytes converts File to bytes.Reader. It saves total file content into memory and suitable for small files.
func (*File) AsFile ¶ added in v0.5.0
func (f *File) AsFile() (io.ReadSeeker, error)
AsFile converts File to a ReadSeeker. The total file content is saved into a temporary file. It's suitable for large files.
func (*File) ContentLength ¶ added in v0.5.0
func (*File) SetMaxSize ¶ added in v0.5.0
type FormDataRequest ¶ added in v0.4.0
type FormDataRequest interface {
NumFiles() int
}
type SniffReadCloser ¶ added in v0.4.0
type SniffReadCloser interface { io.ReadCloser Sniffer }
Click to show internal directories.
Click to hide internal directories.