March 2019
Beginner to intermediate
324 pages
7h 17m
English
For this handler, we expect a URL with a parameter, such as /user/:id/signout. Here is what the handler needs to do:
func (h *Handler) SignOut(c *gin.Context) { if h.db == nil { return } p := c.Param("id") // p is of type string, we need to convert it to an integer type id,err := strconv.Atoi(p) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return }}
Read now
Unlock full access