nytimes

package
v0.0.0-...-1a79bca Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractText

func ExtractText(url string) (string, error)

Given a URL, the text will be extracted (if exist)

func GenerateArticleText

func GenerateArticleText(article *models.Article)

Types

type API

type API struct {
	TopStories TopStories `json:"body"`
	// contains filtered or unexported fields
}

The API for other package to interact with

func NewAPI

func NewAPI() *API

func (*API) FilterBySections

func (a *API) FilterBySections()

Used in controller/article to filter out the "non-news" sections

func (*API) GenerateArticles

func (a *API) GenerateArticles() error

Construct the Article list (TopStories struct). Each Article in the list will only contain the URL, Section, and Title after this call. These are the value returned from NYTimes API.

func (*API) GetArticles

func (a *API) GetArticles() []models.Article

A Get-Set style function to exposes the the articles array through interface

type TopStories

type TopStories struct {
	Articles []models.Article `json:"results"`
}

The json of the response from NYTimes API

Jump to

Keyboard shortcuts

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