mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
Version 11 released. Read https://github.com/kataras/iris/blob/master/HISTORY.md#su-21-october-2018--v1100
Former-commit-id: fe6305deed00e170bf4d39a12c0644fe686e0a24
This commit is contained in:
@@ -68,8 +68,8 @@ func main() {
|
||||
|
||||
// GET: http://localhost:8080/users/42
|
||||
// **/users/42 and /users/help works after iris version 7.0.5**
|
||||
usersRoutes.Get("/{id:int}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetInt("id")
|
||||
usersRoutes.Get("/{id:uint64}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetUint64("id")
|
||||
ctx.Writef("get user by id: %d", id)
|
||||
})
|
||||
|
||||
@@ -80,15 +80,15 @@ func main() {
|
||||
})
|
||||
|
||||
// PUT: http://localhost:8080/users
|
||||
usersRoutes.Put("/{id:int}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetInt("id") // or .Get to get its string represatantion.
|
||||
usersRoutes.Put("/{id:uint64}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetUint64("id") // or .Get to get its string represatantion.
|
||||
username := ctx.PostValue("username")
|
||||
ctx.Writef("update user for id= %d and new username= %s", id, username)
|
||||
})
|
||||
|
||||
// DELETE: http://localhost:8080/users/42
|
||||
usersRoutes.Delete("/{id:int}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetInt("id")
|
||||
usersRoutes.Delete("/{id:uint64}", func(ctx iris.Context) {
|
||||
id, _ := ctx.Params().GetUint64("id")
|
||||
ctx.Writef("delete user by id: %d", id)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user