Documentation
¶
Overview ¶
package api contains the code required to make requests, fetch/stream posts and other things from reddit. This package is heavily inspired by https://github.com/vartanbeno/go-reddit/, you should check it out. But, this package is simpler, smaller and more specialized to the use-case required by me.
Index ¶
- type Client
- func (c *Client) BaseImageURL() *url.URL
- func (c *Client) BaseURL() *url.URL
- func (c *Client) BaseVideoURL() *url.URL
- func (c *Client) Do(ctx context.Context, opts *RequestOptions, method string, body io.Reader) (*http.Response, error)
- func (c *Client) GetImageByURL(ctx context.Context, surl string) (*http.Response, error)
- func (c *Client) GetURL(ctx context.Context, surl string) (*http.Response, error)
- func (c *Client) GetVideoByURL(ctx context.Context, surl string) (*http.Response, error)
- func (c *Client) WithBaseImageURL(u *url.URL) *Client
- func (c *Client) WithBaseURL(u *url.URL) *Client
- func (c *Client) WithBaseVideoURL(u *url.URL) *Client
- func (c *Client) WithTimeout(timeout time.Duration) *Client
- type Image
- type Item
- type Post
- type Posts
- type RequestOptions
- type SubredditService
- type Video
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Subreddit *SubredditService // contains filtered or unexported fields }
This is the client used to make requests in RedditStreamer.Stream().
func DefaultClient ¶
func DefaultClient() *Client
func (*Client) BaseImageURL ¶
func (*Client) BaseVideoURL ¶
func (*Client) GetImageByURL ¶
func (*Client) GetVideoByURL ¶
type Post ¶
type Post struct { Data struct { Media struct { RedditVideo *Video `json:"reddit_video"` } `json:"media"` Title string `json:"title"` URL string `json:"url"` PostHint string `json:"post_hint"` Subreddit string `json:"subreddit"` Preview struct { Images []Image `json:"images"` } Over18 bool `json:"over_18"` IsVideo bool `json:"is_video"` } `json:"data"` }
func (*Post) Dimensions ¶
Dimensions calls p.Width() and p.Height(), then return.
func (*Post) Orientation ¶
Orientation calculates the orientation of video/image.
type RequestOptions ¶
type SubredditService ¶
type SubredditService struct {
// contains filtered or unexported fields
}
func (*SubredditService) GetItems ¶
func (s *SubredditService) GetItems(ctx context.Context, opts *RequestOptions) ([]Item, string, error)
GetItems return a slice of items, "after" string (consult reddit api), or an error.
func (*SubredditService) GetPosts ¶
func (s *SubredditService) GetPosts(ctx context.Context, opts *RequestOptions) ([]Post, string, error)
func (*SubredditService) PostToItem ¶
Click to show internal directories.
Click to hide internal directories.