// ListPeople accepts a request to retrieve a list of people. // // GET /api/people // func ListPeople(c web.C, w http.ResponseWriter, r *http.Request) { var ( ctx = context.FromC(c) limit = handler.ToLimit(r) offset = handler.ToOffset(r) ) people, err := datastore.ListPeople(ctx, limit, offset) if err != nil { log.FromContext(ctx).WithField("err", err).Error("Error listing people") w.WriteHeader(http.StatusNotFound) return } json.NewEncoder(w).Encode(people) }
// ListPeople shows a list of all people // // GET /people // func ListPeople(ctx context.Context, w http.ResponseWriter, r *http.Request) { var ( limit = handler.ToLimit(r) offset = handler.ToOffset(r) ) people, err := datastore.ListPeople(ctx, limit, offset) if err != nil { log.Printf("error: error listing people err=%q", err) w.WriteHeader(http.StatusNotFound) return } renderTemplate(ctx, w, "person_list.tmpl", M{ "People": people, }) }
// ListPeople shows a list of all people // // GET /people // func ListPeople(c web.C, w http.ResponseWriter, r *http.Request) { var ( ctx = context.FromC(c) limit = handler.ToLimit(r) offset = handler.ToOffset(r) ) people, err := datastore.ListPeople(ctx, limit, offset) if err != nil { log.FromContext(ctx).WithField("err", err).Error("Error listing people") w.WriteHeader(http.StatusNotFound) return } renderTemplate(ctx, w, "person_list.tmpl", M{ "People": people, }) }