Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorHandler(exec templates.Executor, w http.ResponseWriter, r *http.Request, err error)
- func PageAndOffset(r *http.Request, pageSize int64) (int64, int64, error)
- func PageCount(total, size int64) int64
- type ErrorInput
- type FromPagination
- func (p *FromPagination[T]) BaseURL() template.URL
- func (p *FromPagination[T]) First() *FromPagination[T]
- func (p *FromPagination[T]) Last() *FromPagination[T]
- func (p *FromPagination[T]) Next(offset int) *FromPagination[T]
- func (p *FromPagination[T]) Prev(offset int) *FromPagination[T]
- func (p *FromPagination[T]) URL() template.URL
- func (p *FromPagination[T]) WithLast(key T, nr int) *FromPagination[T]
- func (p *FromPagination[T]) WithPage(nr int) *FromPagination[T]
- type NewsCache
- func (nc *NewsCache) Empty(post radio.NewsPost)
- func (nc *NewsCache) EmptyBefore(t time.Time)
- func (nc *NewsCache) RenderBody(post radio.NewsPost) (NewsMarkdown, error)
- func (nc *NewsCache) RenderBypass(source string) (NewsMarkdown, error)
- func (nc *NewsCache) RenderBypassCache(post radio.NewsPost) (header, body NewsMarkdown, err error)
- func (nc *NewsCache) RenderComment(comment radio.NewsComment) (NewsMarkdown, error)
- func (nc *NewsCache) RenderError(err error) NewsMarkdown
- func (nc *NewsCache) RenderHeader(post radio.NewsPost) (NewsMarkdown, error)
- type NewsMarkdown
- type Pagination
Constants ¶
const FromTimeFormat = "2006-01-02T15-04-05"
Variables ¶
var ( ErrNotFound = errors.New("page not found") ErrMethodNotAllowed = errors.New("method not allowed") )
Functions ¶
func ErrorHandler ¶
Types ¶
type ErrorInput ¶
type ErrorInput struct { middleware.Input StatusCode int Message string Error error RequestID xid.ID }
func (ErrorInput) TemplateBundle ¶
func (ErrorInput) TemplateBundle() string
type FromPagination ¶
type FromPagination[T constraints.Unsigned] struct { Key T Nr int // contains filtered or unexported fields }
func NewFromPagination ¶
func NewFromPagination[T constraints.Unsigned](key T, prev, next []T, uri *url.URL) *FromPagination[T]
func (*FromPagination[T]) BaseURL ¶
func (p *FromPagination[T]) BaseURL() template.URL
func (*FromPagination[T]) First ¶
func (p *FromPagination[T]) First() *FromPagination[T]
First returns the first page, this uses time.Now() as the Key and 1 as the page number.
func (*FromPagination[T]) Last ¶
func (p *FromPagination[T]) Last() *FromPagination[T]
Last returns the last page, will return nil if WithLast wasn't called beforehand on a parent
func (*FromPagination[T]) Next ¶
func (p *FromPagination[T]) Next(offset int) *FromPagination[T]
Next returns the next page as indicated by the offset from current
func (*FromPagination[T]) Prev ¶
func (p *FromPagination[T]) Prev(offset int) *FromPagination[T]
Prev returns the previous page as indicated by the offset from current
func (*FromPagination[T]) URL ¶
func (p *FromPagination[T]) URL() template.URL
func (*FromPagination[T]) WithLast ¶
func (p *FromPagination[T]) WithLast(key T, nr int) *FromPagination[T]
WithLast returns a page with the last page info set to key and nr
func (*FromPagination[T]) WithPage ¶
func (p *FromPagination[T]) WithPage(nr int) *FromPagination[T]
WithPage returns a page with the page number set to nr
type NewsCache ¶
type NewsCache struct {
// contains filtered or unexported fields
}
func NewNewsCache ¶
func NewNewsCache() *NewsCache
func (*NewsCache) Empty ¶
Empty clears the cache of the post given, this clears the Body and Header cache
func (*NewsCache) EmptyBefore ¶
EmptyBefore removes any entries from the cache that had been generated before the time given
func (*NewsCache) RenderBody ¶
func (nc *NewsCache) RenderBody(post radio.NewsPost) (NewsMarkdown, error)
func (*NewsCache) RenderBypass ¶
func (nc *NewsCache) RenderBypass(source string) (NewsMarkdown, error)
RenderBypass renders string as markdown and skips the cache mechanism, source should come from a trusted input
func (*NewsCache) RenderBypassCache ¶
func (nc *NewsCache) RenderBypassCache(post radio.NewsPost) (header, body NewsMarkdown, err error)
RenderBypassCache renders a news post header and body as markdown and skips the cache mechanism
func (*NewsCache) RenderComment ¶
func (nc *NewsCache) RenderComment(comment radio.NewsComment) (NewsMarkdown, error)
func (*NewsCache) RenderError ¶
func (nc *NewsCache) RenderError(err error) NewsMarkdown
func (*NewsCache) RenderHeader ¶
func (nc *NewsCache) RenderHeader(post radio.NewsPost) (NewsMarkdown, error)
type NewsMarkdown ¶
type Pagination ¶
func NewPagination ¶
func NewPagination(currentPage, totalPages int64, uri *url.URL) *Pagination
func (*Pagination) BaseURL ¶
func (p *Pagination) BaseURL() template.URL
func (*Pagination) First ¶
func (p *Pagination) First() *Pagination
func (*Pagination) Last ¶
func (p *Pagination) Last() *Pagination
func (*Pagination) Next ¶
func (p *Pagination) Next(offset int64) *Pagination
func (*Pagination) Prev ¶
func (p *Pagination) Prev(offset int64) *Pagination
func (*Pagination) URL ¶
func (p *Pagination) URL() template.URL