func handleRequest(c echo.Context) error { name := c.QueryParam("name") age := c.QueryParam("age") // Do something with name and age return c.JSON(http.StatusOK, map[string]string{ "name": name, "age": age, }) }
type User struct { Name string `json:"name"` Age int `json:"age"` } func handleRequest(c echo.Context) error { user := new(User) if err := c.Bind(user); err != nil { return err } // Do something with user.Name and user.Age return c.JSON(http.StatusOK, user) }In this example, we have a JSON request body representing a `User` struct. We use the `Bind` method to parse the request body into a new instance of `User`. We then use the values of `user.Name` and `user.Age` to do some processing and return a JSON response. Overall, the Context Param package library in Go provides invaluable tools for handling request parameters in HTTP servers.