class Edit(BaseHandler, Jinja2Rendering): @auth_admin def get(self, user_id): """Display a user profile """
Not sure how to do that in my func(c *context) UserEdit(rw web.ResponseWriter, req *web.Request) {}
On my list page I have the list of users and when you click on one you get to the user edit page.I get from my list page to my edit page like sorootRouter.Get("/user/edit/:user_id", (*Context).UserEdit)In python I get the user_id from params. How does that work in go?You can capture path variables like this:
router.Get("/suggestions/:suggestion_id/comments/:comment_id")
In your handler, you can access them like this:
func (c *YourContext) Root(rw web.ResponseWriter, req *web.Request) { fmt.Fprint(rw, "Suggestion ID:", req.PathParams["suggestion_id"]) fmt.Fprint(rw, "Comment ID:", req.PathParams["comment_id"]) }
You can also validate the format of your path params with a regexp. For instance, to ensure the 'ids' start with a digit:
router.Get("/suggestions/:suggestion_id:\\d.*/comments/:comment_id:\\d.*")