Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.With(paginate) in documentation #907

Closed
bigusef opened this issue Apr 9, 2024 · 1 comment
Closed

r.With(paginate) in documentation #907

bigusef opened this issue Apr 9, 2024 · 1 comment

Comments

@bigusef
Copy link

bigusef commented Apr 9, 2024

Hi, I'm new in Golang, and I using Chi in any tutorials project I have now to learn Go.
in this link, I found

r.Route("/articles", func(r chi.Router) {
    r.With(paginate).Get("/", listArticles)                           // GET /articles
    r.With(paginate).Get("/{month}-{day}-{year}", listArticlesByDate) // GET /articles/01-16-2017

    r.Post("/", createArticle)                                        // POST /articles
    r.Get("/search", searchArticles)                                  // GET /articles/search

    // Regexp url parameters:
    r.Get("/{articleSlug:[a-z-]+}", getArticleBySlug)                // GET /articles/home-is-toronto

    // Subrouters:
    r.Route("/{articleID}", func(r chi.Router) {
      r.Use(ArticleCtx)
      r.Get("/", getArticle)                                          // GET /articles/123
      r.Put("/", updateArticle)                                       // PUT /articles/123
      r.Delete("/", deleteArticle)                                    // DELETE /articles/123
    })
  })

but I don't know what are paginate and what meaning of it

@VojtechVitek
Copy link
Contributor

Hi, please use Discussions or Stack Overflow for general questions.

Paginate in this case would be a Middleware. See

func paginate(next http.Handler) http.Handler {
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants