mirror of
https://github.com/astaxie/beego.git
synced 2025-07-04 15:50:18 +00:00
move under context
This commit is contained in:
31
context/param/options.go
Normal file
31
context/param/options.go
Normal file
@ -0,0 +1,31 @@
|
||||
package param
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type MethodParamOption func(*MethodParam)
|
||||
|
||||
var IsRequired MethodParamOption = func(p *MethodParam) {
|
||||
p.required = true
|
||||
}
|
||||
|
||||
var InHeader MethodParamOption = func(p *MethodParam) {
|
||||
p.location = header
|
||||
}
|
||||
|
||||
var InPath MethodParamOption = func(p *MethodParam) {
|
||||
p.location = path
|
||||
}
|
||||
|
||||
var InBody MethodParamOption = func(p *MethodParam) {
|
||||
p.location = body
|
||||
}
|
||||
|
||||
func Default(defValue interface{}) MethodParamOption {
|
||||
return func(p *MethodParam) {
|
||||
if defValue != nil {
|
||||
p.defValue = fmt.Sprint(defValue)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user