{"id":29857974,"url":"https://github.com/webstradev/echo-pagination","last_synced_at":"2025-07-30T01:21:44.178Z","repository":{"id":259440600,"uuid":"876732954","full_name":"webstradev/echo-pagination","owner":"webstradev","description":"Simple pagination middleware for the echo framework. Allows for the usage of url parameters like ?page=1\u0026size=25 to paginate data on your API.","archived":false,"fork":false,"pushed_at":"2025-05-26T19:50:23.000Z","size":39,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-28T08:50:26.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webstradev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-22T13:19:59.000Z","updated_at":"2025-05-26T19:49:32.000Z","dependencies_parsed_at":"2024-10-25T12:28:42.598Z","dependency_job_id":"259535ee-da74-4806-af75-546aef1c3047","html_url":"https://github.com/webstradev/echo-pagination","commit_stats":null,"previous_names":["webstradev/echo-pagination"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/webstradev/echo-pagination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webstradev%2Fecho-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webstradev%2Fecho-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webstradev%2Fecho-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webstradev%2Fecho-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webstradev","download_url":"https://codeload.github.com/webstradev/echo-pagination/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webstradev%2Fecho-pagination/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267791223,"owners_count":24144919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-30T01:21:41.713Z","updated_at":"2025-07-30T01:21:44.159Z","avatar_url":"https://github.com/webstradev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# echo-pagination\n[![Run Tests](https://github.com/webstradev/echo-pagination/actions/workflows/test.yml/badge.svg)](https://github.com/webstradev/echo-pagination/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/webstradev/echo-pagination/graph/badge.svg?token=QCOW8N4AUR)](https://codecov.io/gh/webstradev/echo-pagination)\n[![Go Reference](https://pkg.go.dev/badge/github.com/webstradev/echo-pagination.svg)](https://pkg.go.dev/github.com/webstradev/echo-pagination)\n[![Go Report Card](https://goreportcard.com/badge/github.com/webstradev/echo-pagination)](https://goreportcard.com/report/github.com/webstradev/echo-pagination)\n[![CodeQL](https://github.com/webstradev/echo-pagination/actions/workflows/codeql.yml/badge.svg)](https://github.com/webstradev/echo-pagination/actions/workflows/codeql.yml)\n\nSimple pagination middleware for the echo framework. Allows for the usage of url parameters like `?page=1\u0026size=25` to paginate data on your API.\n\n# Installation\n```bash\n$ go get github.com/webstradev/echo-pagination\n```\n\n# Default Usage\nThis package comes with various default options that are configurable using functional options. By default the paginator will use the query parameters `page` and `size` with values of `1` and `10` and a maximum page size of `100`.\n\n### Using the middleware on a router will apply it to all requests on that router:\n```go\npackage main\n\nimport (\n  \"net/http\"\n\n  \"github.com/labstack/echo/v4\"\n  \"github.com/webstradev/echo-pagination/pkg/pagination\"\n)\n\nfunc main(){\n  e := echo.New()\n  e.Use(pagination.New())\n\n  e.GET(\"/hello\", func(c echo.Context) error {\n    return c.Status(http.StatusOK)  \n  })\n  \n\te.Logger.Fatal(e.Start(\":1323\"))\n}\n```\n\n#### Using the middleware on a single route will only apply it to that route:\n```go\npackage main\n\nimport (\n  \"net/http\"\n\n  \"github.com/labstack/echo/v4\"\n  \"github.com/webstradev/echo-pagination/pkg/pagination\"\n)\n\nfunc main(){\n  e := echo.New()\n  \n  e.GET(\"/hello\", func(c echo.Context){\n    page := c.GetInt(\"page\")\n  \n\t\treturn c.String(http.StatusOK, \"Hello, World!\")\n  }, pagination.New())\n  \n\te.Logger.Fatal(e.Start(\":1323\"))\n}\n```\nThe `page` and `size` are now available in the echo context of a request and can be used to paginate your data (for example in an SQL query).\n\n## Custom Usage\nTo create a pagination middleware with custom parameters the New() function supports various custom options provided as functions that overwrite the default value.\nAll the options can be seen in the example below.\n```go\npackage main\n\nimport (\n  \"net/http\"\n  \n  \"github.com/labstack/echo/v4\"\n  \"github.com/webstradev/echo-pagination/pkg/pagination\"\n)\n\nfunc main(){\n  e := echo.New()\n  \n  paginator := pagination.New(\n    pagination.WithPageText(\"page\"), \n    pagination.WithSizeText(\"rowsPerPage\"),\n    pagination.WithDefaultPage(1),\n    pagination.WithDefaultPageSize(15),\n    pagination.WithMinPageSize(5),\n    pagination.WithMaxPageSize(15),\n  )\n  \n  e.GET(\"/hello\", func(c echo.Context){\n    return c.String(http.StatusOK, \"Hello, World!\")\n  }, paginator)\n  \n\te.Logger.Fatal(e.Start(\":1323\"))\n}\n```\n\nThe custom middleware can also be used on an entire router object similarly to the first example fo the Default Usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebstradev%2Fecho-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebstradev%2Fecho-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebstradev%2Fecho-pagination/lists"}