Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
cb4f252a
Commit
cb4f252a
authored
May 11, 2017
by
Eyal Post
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defValue -> defaultValue
parent
d3a16dca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
13 deletions
+10
-13
conv.go
context/param/conv.go
+1
-4
methodparams.go
context/param/methodparams.go
+6
-6
options.go
context/param/options.go
+3
-3
No files found.
context/param/conv.go
View file @
cb4f252a
...
...
@@ -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
.
def
ault
Value
}
}
...
...
@@ -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
:
...
...
context/param/methodparams.go
View file @
cb4f252a
...
...
@@ -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
def
ault
Value
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
.
def
ault
Value
!=
""
{
options
=
append
(
options
,
fmt
.
Sprintf
(
`param.Default("%s")`
,
mp
.
def
ault
Value
))
}
if
len
(
options
)
>
0
{
result
+=
", "
...
...
context/param/options.go
View file @
cb4f252a
...
...
@@ -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
(
def
ault
Value
interface
{})
MethodParamOption
{
return
func
(
p
*
MethodParam
)
{
if
defValue
!=
nil
{
p
.
def
Value
=
fmt
.
Sprint
(
def
Value
)
if
def
ault
Value
!=
nil
{
p
.
def
aultValue
=
fmt
.
Sprint
(
default
Value
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment