2017-04-21 12:26:41 +00:00
|
|
|
package param
|
|
|
|
|
2017-04-22 22:33:50 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2017-04-25 13:00:49 +00:00
|
|
|
type MethodParamOption func(*MethodParam)
|
|
|
|
|
2017-04-22 22:33:50 +00:00
|
|
|
var IsRequired MethodParamOption = func(p *MethodParam) {
|
|
|
|
p.required = true
|
|
|
|
}
|
|
|
|
|
2017-04-21 12:26:41 +00:00
|
|
|
var InHeader MethodParamOption = func(p *MethodParam) {
|
|
|
|
p.location = header
|
|
|
|
}
|
|
|
|
|
2017-04-25 13:00:49 +00:00
|
|
|
var InPath MethodParamOption = func(p *MethodParam) {
|
|
|
|
p.location = path
|
|
|
|
}
|
|
|
|
|
2017-04-22 22:33:50 +00:00
|
|
|
var InBody MethodParamOption = func(p *MethodParam) {
|
|
|
|
p.location = body
|
2017-04-21 12:26:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Default(defValue interface{}) MethodParamOption {
|
|
|
|
return func(p *MethodParam) {
|
2017-04-22 22:33:50 +00:00
|
|
|
if defValue != nil {
|
2017-04-23 23:35:04 +00:00
|
|
|
p.defValue = fmt.Sprint(defValue)
|
2017-04-22 22:33:50 +00:00
|
|
|
}
|
2017-04-21 12:26:41 +00:00
|
|
|
}
|
|
|
|
}
|