func getUsers(c *gin.Context) { name := c.Query("name") age := c.Query("age") // ... code to retrieve users with the given name and age }
func middleware(c *gin.Context) { isAdmin := c.Query("isAdmin") if isAdmin == "true" { // ... code to check if the user is an admin } else { // ... code to check if the user is a regular user } // ... code to pass control back to the main handler }In this example, the `Query` method of the context object is used to retrieve the value of the "isAdmin" parameter in the URL. Depending on its value, the appropriate code path is executed. Overall, the `gin.Context` object in the gin-gonic/gin package provides developers with easy access to query parameters in the URL, which can be used to build flexible and dynamic web applications.