mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 12:21:28 +00:00
32 lines
544 B
Go
32 lines
544 B
Go
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)
|
|
}
|
|
}
|
|
}
|