forked from ggicci/httpin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
40 lines (36 loc) · 1.06 KB
/
options.go
File metadata and controls
40 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package httpin
type Option func(*Engine) error
// WithErrorHandler overrides the default error handler.
func WithErrorHandler(custom ErrorHandler) Option {
return func(c *Engine) error {
if custom == nil {
return ErrNilErrorHandler
}
c.errorHandler = custom
return nil
}
}
// WithMaxMemory overrides the default maximum memory size (32MB) when reading
// the request body. See https://pkg.go.dev/net/http#Request.ParseMultipartForm
// for more details.
func WithMaxMemory(maxMemory int64) Option {
return func(c *Engine) error {
if maxMemory < minimumMaxMemory {
return ErrMaxMemoryTooSmall
}
c.maxMemory = maxMemory
return nil
}
}
// WithTypeDecoder overrides the default type decoder.
// The decoder can be type of ValueTypeDecoder or FileTypeDecoder.
// func WithTypeDecoder(typ reflect.Type, decoder interface{}) Option {
// ensureValidDecoder(typ, decoder)
// return func(c *Engine) error {
// if c.typeDecoders == nil {
// c.typeDecoders = make(map[reflect.Type]interface{})
// }
// c.typeDecoders[typ] = decoder
// return nil
// }
// }