Skip to content

Commit

Permalink
add demo
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhihao committed Sep 14, 2022
1 parent 4afa590 commit 979ab13
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions demo/GetParams/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ func (testHandler *TestHandler) Post() {
}
}

func (testHandler *TestHandler) Get() {
userId, _ := testHandler.GetPathParam("userId").ToInt()
result := map[string]interface{}{
"id": userId,
"name": "Three Zhang",
"desc": "this is test info",
}
isShowExtra := testHandler.GetPathParam("isShowExtra").ToBool()
if isShowExtra {
result["extra"] = "this is extra info"
}
testHandler.ResponseAsJson(result)
}

var url = []TigoWeb.Pattern{
{"/test", TestHandler{}, nil},
{"/user/{userId}/info/{isShowExtra}", TestHandler{}, nil},
Expand Down

0 comments on commit 979ab13

Please sign in to comment.