Skip to content
Permalink
Browse files

Loosen dependency on pop (#1621)

* Use paginable interface instead of pop.Paginator.
* Migrate pop/nulls to gobuffalo/nulls.
  • Loading branch information...
stanislas-m committed Mar 9, 2019
1 parent 79c6af1 commit aa552ab9618d4111a969cc876c0e0e7f889cf5b8
Showing with 8 additions and 5 deletions.
  1. +1 −1 binding/binding.go
  2. +6 −3 default_context.go
  3. +1 −1 go.mod
@@ -8,7 +8,7 @@ import (
"sync"
"time"

"github.com/gobuffalo/pop/nulls"
"github.com/gobuffalo/nulls"
"github.com/gobuffalo/x/httpx"
"github.com/monoculum/formam"
"github.com/pkg/errors"
@@ -16,7 +16,6 @@ import (

"github.com/gobuffalo/buffalo/binding"
"github.com/gobuffalo/buffalo/render"
"github.com/gobuffalo/pop"
"github.com/pkg/errors"
)

@@ -101,6 +100,10 @@ func (d *DefaultContext) Flash() *Flash {
return d.flash
}

type paginable interface {
Paginate() string
}

// Render a status code and render.Renderer to the associated Response.
// The request parameters will be made available to the render.Renderer
// "{{.params}}". Any values set onto the Context will also automatically
@@ -138,8 +141,8 @@ func (d *DefaultContext) Render(status int, rr render.Renderer) error {
}

d.Response().Header().Set("Content-Type", rr.ContentType())
if p, ok := data["pagination"].(*pop.Paginator); ok {
d.Response().Header().Set("X-Pagination", p.String())
if p, ok := data["pagination"].(paginable); ok {
d.Response().Header().Set("X-Pagination", p.Paginate())
}
d.Response().WriteHeader(status)
_, err = io.Copy(d.Response(), bb)
2 go.mod
@@ -19,7 +19,7 @@ require (
github.com/gobuffalo/httptest v1.1.0
github.com/gobuffalo/logger v0.0.0-20190224201004-be78ebfea0fa
github.com/gobuffalo/meta v0.0.0-20190207205153-50a99e08b8cf
github.com/gobuffalo/nulls v0.0.0-20190305142546-85f3c9250d87 // indirect
github.com/gobuffalo/nulls v0.0.0-20190305142546-85f3c9250d87
github.com/gobuffalo/packd v0.0.0-20190224160250-d04dd98aca5b
github.com/gobuffalo/packr v1.22.0
github.com/gobuffalo/packr/v2 v2.0.3

0 comments on commit aa552ab

Please sign in to comment.
You can’t perform that action at this time.