From cb4f252a06455ac1a4f9e15d7d83e3c33cd188fb Mon Sep 17 00:00:00 2001 From: Eyal Post Date: Thu, 11 May 2017 17:58:25 +0300 Subject: [PATCH] defValue -> defaultValue --- context/param/conv.go | 5 +---- context/param/methodparams.go | 12 ++++++------ context/param/options.go | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/context/param/conv.go b/context/param/conv.go index e961b4ad..596d2b1e 100644 --- a/context/param/conv.go +++ b/context/param/conv.go @@ -24,7 +24,7 @@ func convertParam(param *MethodParam, paramType reflect.Type, ctx *beecontext.Co if param.required { ctx.Abort(400, fmt.Sprintf("Missing parameter %s", param.name)) } else { - paramValue = param.defValue + paramValue = param.defaultValue } } @@ -43,9 +43,6 @@ func getParamValue(param *MethodParam, ctx *beecontext.Context) string { return string(ctx.Input.RequestBody) case header: 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: return ctx.Input.Query(":" + param.name) default: diff --git a/context/param/methodparams.go b/context/param/methodparams.go index 28772504..fe4ab421 100644 --- a/context/param/methodparams.go +++ b/context/param/methodparams.go @@ -7,10 +7,10 @@ import ( //MethodParam keeps param information to be auto passed to controller methods type MethodParam struct { - name string - location paramLocation - required bool - defValue string + name string + location paramLocation + required bool + defaultValue string } type paramLocation byte @@ -57,8 +57,8 @@ func (mp *MethodParam) String() string { case header: options = append(options, "param.InHeader") } - if mp.defValue != "" { - options = append(options, fmt.Sprintf(`param.Default("%s")`, mp.defValue)) + if mp.defaultValue != "" { + options = append(options, fmt.Sprintf(`param.Default("%s")`, mp.defaultValue)) } if len(options) > 0 { result += ", " diff --git a/context/param/options.go b/context/param/options.go index 846a59f6..32402194 100644 --- a/context/param/options.go +++ b/context/param/options.go @@ -28,10 +28,10 @@ var InBody MethodParamOption = func(p *MethodParam) { } // Default provides a default value for the http param -func Default(defValue interface{}) MethodParamOption { +func Default(defaultValue interface{}) MethodParamOption { return func(p *MethodParam) { - if defValue != nil { - p.defValue = fmt.Sprint(defValue) + if defaultValue != nil { + p.defaultValue = fmt.Sprint(defaultValue) } } }