func FindUser(c web.C, w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") username := c.URLParams["user"] userModel := models.FindByUsername(username) u := User{ Username: username, Name: userModel.Name, Clicks: userModel.Clicks, } res, _ := json.Marshal(u) w.Write(res) }
func FindUserProto(c web.C, w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/x-protobuf") username := c.URLParams["user"] userModel := models.FindByUsername(username) u := UserProto{ Username: username, Name: userModel.Name, Clicks: int64(userModel.Clicks), } fmt.Println(u) protoRes, _ := proto.Marshal(&u) w.Write(protoRes) }