mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 04:01:29 +00:00
defValue -> defaultValue
This commit is contained in:
parent
d3a16dca85
commit
cb4f252a06
@ -24,7 +24,7 @@ func convertParam(param *MethodParam, paramType reflect.Type, ctx *beecontext.Co
|
|||||||
if param.required {
|
if param.required {
|
||||||
ctx.Abort(400, fmt.Sprintf("Missing parameter %s", param.name))
|
ctx.Abort(400, fmt.Sprintf("Missing parameter %s", param.name))
|
||||||
} else {
|
} else {
|
||||||
paramValue = param.defValue
|
paramValue = param.defaultValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,9 +43,6 @@ func getParamValue(param *MethodParam, ctx *beecontext.Context) string {
|
|||||||
return string(ctx.Input.RequestBody)
|
return string(ctx.Input.RequestBody)
|
||||||
case header:
|
case header:
|
||||||
return ctx.Input.Header(param.name)
|
return ctx.Input.Header(param.name)
|
||||||
// if strValue == "" && strings.Contains(param.name, "_") { //magically handle X-Headers?
|
|
||||||
// strValue = ctx.Input.Header(strings.Replace(param.name, "_", "-", -1))
|
|
||||||
// }
|
|
||||||
case path:
|
case path:
|
||||||
return ctx.Input.Query(":" + param.name)
|
return ctx.Input.Query(":" + param.name)
|
||||||
default:
|
default:
|
||||||
|
@ -10,7 +10,7 @@ type MethodParam struct {
|
|||||||
name string
|
name string
|
||||||
location paramLocation
|
location paramLocation
|
||||||
required bool
|
required bool
|
||||||
defValue string
|
defaultValue string
|
||||||
}
|
}
|
||||||
|
|
||||||
type paramLocation byte
|
type paramLocation byte
|
||||||
@ -57,8 +57,8 @@ func (mp *MethodParam) String() string {
|
|||||||
case header:
|
case header:
|
||||||
options = append(options, "param.InHeader")
|
options = append(options, "param.InHeader")
|
||||||
}
|
}
|
||||||
if mp.defValue != "" {
|
if mp.defaultValue != "" {
|
||||||
options = append(options, fmt.Sprintf(`param.Default("%s")`, mp.defValue))
|
options = append(options, fmt.Sprintf(`param.Default("%s")`, mp.defaultValue))
|
||||||
}
|
}
|
||||||
if len(options) > 0 {
|
if len(options) > 0 {
|
||||||
result += ", "
|
result += ", "
|
||||||
|
@ -28,10 +28,10 @@ var InBody MethodParamOption = func(p *MethodParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default provides a default value for the http param
|
// Default provides a default value for the http param
|
||||||
func Default(defValue interface{}) MethodParamOption {
|
func Default(defaultValue interface{}) MethodParamOption {
|
||||||
return func(p *MethodParam) {
|
return func(p *MethodParam) {
|
||||||
if defValue != nil {
|
if defaultValue != nil {
|
||||||
p.defValue = fmt.Sprint(defValue)
|
p.defaultValue = fmt.Sprint(defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user