// ListUsersHandler gets all Users. This function is mapped to the path
// GET /users
ListUsersHandler gets all Users. This function is mapped to the path
GET /users
// ListUsersHandler gets all Users . This function is mapped to the path // GET / users
func ListUsersHandler(c buffalo.Context) error {
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return fmt.Errorf("no transaction found")
	}
	users := &models.Users{}
	q := tx.PaginateFromParams(c.Params())
	if err := q.Order("name asc").All(users); err != nil {
		return err
	}
	return responder.Wants("html", func(c buffalo.Context) error {
		c.Set("pagination", q.Paginator)
		c.Set("users", users)
		return c.Render(http.StatusOK, r.HTML("/users/index.plush.html"))
	}).Wants("json", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.JSON(users))
	}).Wants("xml", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.XML(users))
	}).Respond(c)
}
func ListUsersHandler ( c buffalo . Context ) error { tx , ok := c . Value ( " " ) . ( * pop . Connection ) if ! ok { return fmt . Errorf ( " " ) } users := & models . Users { } q := tx . PaginateFromParams ( c . Params ( ) ) if err := q . Order ( " " ) . All ( users ) ; err != nil { return err } return responder . Wants ( " " , func ( c buffalo . Context ) error { c . Set ( " " , q . Paginator ) c . Set ( " " , users ) return c . Render ( http . StatusOK , r . HTML ( " " ) ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . JSON ( users ) ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . XML ( users ) ) } ) . Respond ( c ) }
ListUsersHandler gets all Users.
ListUsersHandler gets all Users .
// func (v UsersResource) List(c buffalo.Context) error { // Get the DB connection from the context // Paginate results. Params "page" and "per_page" control pagination. // Default values are "page=1" and "per_page=20". // Retrieve all Users from the DB // Add the paginator to the context so it can be used in the template.