From 979ab13602aba51dec7bcb870daa4980f50274fd Mon Sep 17 00:00:00 2001 From: lizhihao Date: Wed, 14 Sep 2022 16:10:44 +0800 Subject: [PATCH] add demo --- demo/GetParams/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/demo/GetParams/main.go b/demo/GetParams/main.go index 0a5aa7e..6b99a2f 100644 --- a/demo/GetParams/main.go +++ b/demo/GetParams/main.go @@ -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},