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
a99802b7
Commit
a99802b7
authored
Apr 10, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego:query data from Form & params
parent
3e16feb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
input.go
context/input.go
+3
-0
controller.go
controller.go
+5
-8
No files found.
context/input.go
View file @
a99802b7
...
...
@@ -211,6 +211,9 @@ func (input *BeegoInput) Param(key string) string {
// Query returns input data item string by a given string.
func
(
input
*
BeegoInput
)
Query
(
key
string
)
string
{
if
val
:=
input
.
Param
(
key
);
val
!=
""
{
return
val
}
if
input
.
Request
.
Form
==
nil
{
input
.
Request
.
ParseForm
()
}
...
...
controller.go
View file @
a99802b7
...
...
@@ -285,10 +285,7 @@ func (c *Controller) ServeXml() {
// Input returns the input data map from POST or PUT request body and query string.
func
(
c
*
Controller
)
Input
()
url
.
Values
{
ct
:=
c
.
Ctx
.
Request
.
Header
.
Get
(
"Content-Type"
)
if
strings
.
Contains
(
ct
,
"multipart/form-data"
)
{
c
.
Ctx
.
Request
.
ParseMultipartForm
(
MaxMemory
)
//64MB
}
else
{
if
c
.
Ctx
.
Request
.
Form
==
nil
{
c
.
Ctx
.
Request
.
ParseForm
()
}
return
c
.
Ctx
.
Request
.
Form
...
...
@@ -301,7 +298,7 @@ func (c *Controller) ParseForm(obj interface{}) error {
// GetString returns the input value by key string.
func
(
c
*
Controller
)
GetString
(
key
string
)
string
{
return
c
.
Input
()
.
Get
(
key
)
return
c
.
Ctx
.
Input
.
Query
(
key
)
}
// GetStrings returns the input string slice by key string.
...
...
@@ -320,17 +317,17 @@ func (c *Controller) GetStrings(key string) []string {
// GetInt returns input value as int64.
func
(
c
*
Controller
)
GetInt
(
key
string
)
(
int64
,
error
)
{
return
strconv
.
ParseInt
(
c
.
Input
()
.
Get
(
key
),
10
,
64
)
return
strconv
.
ParseInt
(
c
.
Ctx
.
Input
.
Query
(
key
),
10
,
64
)
}
// GetBool returns input value as bool.
func
(
c
*
Controller
)
GetBool
(
key
string
)
(
bool
,
error
)
{
return
strconv
.
ParseBool
(
c
.
Input
()
.
Get
(
key
))
return
strconv
.
ParseBool
(
c
.
Ctx
.
Input
.
Query
(
key
))
}
// GetFloat returns input value as float64.
func
(
c
*
Controller
)
GetFloat
(
key
string
)
(
float64
,
error
)
{
return
strconv
.
ParseFloat
(
c
.
Input
()
.
Get
(
key
),
64
)
return
strconv
.
ParseFloat
(
c
.
Ctx
.
Input
.
Query
(
key
),
64
)
}
// GetFile returns the file data in file upload field named as key.
...
...
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