Beispiel #1
0
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)

}
Beispiel #2
0
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)
}