diff --git a/context/param/conv.go b/context/param/conv.go index 596d2b1e..c200e008 100644 --- a/context/param/conv.go +++ b/context/param/conv.go @@ -38,7 +38,7 @@ func convertParam(param *MethodParam, paramType reflect.Type, ctx *beecontext.Co } func getParamValue(param *MethodParam, ctx *beecontext.Context) string { - switch param.location { + switch param.in { case body: return string(ctx.Input.RequestBody) case header: diff --git a/context/param/methodparams.go b/context/param/methodparams.go index fe4ab421..cd6708a2 100644 --- a/context/param/methodparams.go +++ b/context/param/methodparams.go @@ -8,15 +8,15 @@ import ( //MethodParam keeps param information to be auto passed to controller methods type MethodParam struct { name string - location paramLocation + in paramType required bool defaultValue string } -type paramLocation byte +type paramType byte const ( - param paramLocation = iota + param paramType = iota path body header @@ -49,7 +49,7 @@ func (mp *MethodParam) String() string { if mp.required { options = append(options, "param.IsRequired") } - switch mp.location { + switch mp.in { case path: options = append(options, "param.InPath") case body: diff --git a/context/param/options.go b/context/param/options.go index 32402194..58bdc3d0 100644 --- a/context/param/options.go +++ b/context/param/options.go @@ -14,17 +14,17 @@ var IsRequired MethodParamOption = func(p *MethodParam) { // InHeader indicates that this param is passed via an http header var InHeader MethodParamOption = func(p *MethodParam) { - p.location = header + p.in = header } // InPath indicates that this param is part of the URL path var InPath MethodParamOption = func(p *MethodParam) { - p.location = path + p.in = path } // InBody indicates that this param is passed as an http request body var InBody MethodParamOption = func(p *MethodParam) { - p.location = body + p.in = body } // Default provides a default value for the http param diff --git a/context/param/parsers.go b/context/param/parsers.go index 2b48e878..421aecf0 100644 --- a/context/param/parsers.go +++ b/context/param/parsers.go @@ -21,7 +21,7 @@ func getParser(param *MethodParam, t reflect.Type) paramParser { if t.Elem().Kind() == reflect.Uint8 { //treat []byte as string return stringParser{} } - if param.location == body { + if param.in == body { return jsonParser{} } elemParser := getParser(param, t.Elem()) diff --git a/context/param/parsers_test.go b/context/param/parsers_test.go index cc97c735..b946ba08 100644 --- a/context/param/parsers_test.go +++ b/context/param/parsers_test.go @@ -43,7 +43,7 @@ func Test_Parsers(t *testing.T) { checkParser(testDefinition{`1,2`, []int{1, 2}, sliceParser(intParser{})}, t) //slice in body is parsed as json - checkParser(testDefinition{`["a","b"]`, []string{"a", "b"}, jsonParser{}}, t, MethodParam{location: body}) + checkParser(testDefinition{`["a","b"]`, []string{"a", "b"}, jsonParser{}}, t, MethodParam{in: body}) //pointers var someInt = 1