wpapi

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomTime

type CustomTime struct {
	time.Time
}

CustomTime time with custom parse format.

func (*CustomTime) UnmarshalJSON

func (ct *CustomTime) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal JSON with custom time format.

type PageCache added in v0.9.0

type PageCache struct {
	DB  *badger.DB
	Dir string
	TTL time.Duration
}

func NewPageCache added in v0.9.0

func NewPageCache() (*PageCache, error)

func (*PageCache) Close added in v0.9.0

func (c *PageCache) Close() error

func (*PageCache) Get added in v0.9.0

func (c *PageCache) Get(page int) (WPPosts, error)

func (*PageCache) Set added in v0.9.0

func (c *PageCache) Set(page int, posts *WPPosts) error

type WPError

type WPError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Data    struct {
		Status int `json:"status"`
	} `json:"data"`
}

WPError is WordPress API error object.

func (WPError) Error

func (e WPError) Error() string

type WPPost

type WPPost struct {
	Link      string     `json:"link"`
	Type      string     `json:"type"`
	Status    string     `json:"status"`
	Slug      string     `json:"slug"`
	Lang      string     `json:"lang"`
	CreatedAt CustomTime `json:"date_gmt"`
	UpdatedAt CustomTime `json:"modified_gmt"`
	Title     struct {
		Rendered string `json:"rendered"`
	} `json:"title"`
	Key struct {
		Type struct {
			Name string `json:"name"`
		} `json:"key_type"`
		Location struct {
			Name string `json:"name"`
		} `json:"key_location"`
		Hosting struct {
			Name string `json:"name"`
		} `json:"key_hosting"`
		Quality string `json:"key_quality"`
		SS      string `json:"key_ss"`
	} `json:"acf"`
}

WPPost is WordPress API post object.

func (*WPPost) IsValid

func (p *WPPost) IsValid() bool

IsValid filters posts for the wpapi.

type WPPosts

type WPPosts []WPPost

WPPosts is WPPost slice.

func AllPosts

func AllPosts() (WPPosts, error)

AllPosts fetches all WordPress posts.

func Posts

func Posts(page int, limit int, cache *PageCache) (WPPosts, error)

Posts fetches WordPress API page with posts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL