forked from kataras/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement ReadQuery with 'url' struct field tag name strictly, as req…
…uested at: kataras#1207 Former-commit-id: dc0c237f62aa6db5a0c1755b2074d8a18dba0d8f
- Loading branch information
Showing
8 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// package main contains an example on how to use the ReadForm, but with the same way you can do the ReadJSON & ReadJSON | ||
package main | ||
|
||
import ( | ||
"github.com/kataras/iris" | ||
) | ||
|
||
type MyType struct { | ||
Name string `url:"name"` | ||
Age int `url:"age"` | ||
} | ||
|
||
func main() { | ||
app := iris.New() | ||
|
||
app.Get("/", func(ctx iris.Context) { | ||
var t MyType | ||
err := ctx.ReadQuery(&t) | ||
if err != nil && !iris.IsErrPath(err) { | ||
ctx.StatusCode(iris.StatusInternalServerError) | ||
ctx.WriteString(err.Error()) | ||
} | ||
|
||
ctx.Writef("MyType: %#v", t) | ||
}) | ||
|
||
// http://localhost:8080?name=iris&age=3 | ||
app.Run(iris.Addr(":8080")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters