greader_api

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddSubscriptionResult

type AddSubscriptionResult struct {
	NumResults int    `json:"numResults"`
	Error      string `json:"error"`
	FeedID     string `json:"streamId"`
}

type AlternateLocation

type AlternateLocation struct {
	URL string `json:"href"`
}

type Category

type Category struct {
	ID    string `json:"id"` // "user/-/label/未分类"
	Label string `json:"label"`
}

func BuildCategories

func BuildCategories(names []string) []*Category

func BuildCategory

func BuildCategory(name string) *Category

type ClientConfig

type ClientConfig struct {
	Backend     IGReaderBackend
	Logger      ILogger
	FetchLogger ILogger
}

type Entry

type Entry struct {
	ID     string `json:"id"`
	Title  string `json:"title"`
	Author string `json:"author"`

	PublishedTimestamp int64  `json:"published"`
	CrawledTimestamp   string `json:"crawlTimeMsec"`
	TimestampUsec      string `json:"timestampUsec"`

	Summary    *EntrySummary        `json:"summary"`
	Alternates []*AlternateLocation `json:"alternate"`
	Categories []string             `json:"categories"`
	Origin     *EntryOrigin         `json:"origin"`
}

type EntryOrigin

type EntryOrigin struct {
	StreamID string `json:"streamId,omitempty"`
	Title    string `json:"title,omitempty"`
}

type EntrySummary

type EntrySummary struct {
	Content string `json:"content"`
}

type GReader

type GReader struct {
	// contains filtered or unexported fields
}

func New

func New(config *ClientConfig) *GReader

func (*GReader) AddSubscription

func (r *GReader) AddSubscription(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) Auth

func (r *GReader) Auth(ctx context.Context, reader HttpReader, writer http.ResponseWriter)

func (*GReader) EditSubscription

func (r *GReader) EditSubscription(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) EditSubscriptionStatus

func (r *GReader) EditSubscriptionStatus(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) FetchRss

func (r *GReader) FetchRss() error

func (*GReader) FetchRssBackend

func (r *GReader) FetchRssBackend()

func (*GReader) ListItemIDs

func (r *GReader) ListItemIDs(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) ListSubscription

func (r *GReader) ListSubscription(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) LoadItem

func (r *GReader) LoadItem(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) Routers

func (r *GReader) Routers() map[[2]string]func(ctx context.Context, reader HttpReader, writer http.ResponseWriter)

func (*GReader) ServeHTTP

func (r *GReader) ServeHTTP(writer http.ResponseWriter, request *http.Request)

func (*GReader) TagDelete

func (r *GReader) TagDelete(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) TagList

func (r *GReader) TagList(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) TagRename

func (r *GReader) TagRename(ctx context.Context, req HttpReader, writer http.ResponseWriter)

func (*GReader) Token

func (r *GReader) Token(ctx context.Context, req HttpReader, writer http.ResponseWriter)

type HttpReader

type HttpReader interface {
	FormList(key string) []string
	FormString(key string) string
	HeaderString(key string) string
	QueryString(key string) string
}

func WrapStdHttpRequest

func WrapStdHttpRequest(request *http.Request) HttpReader

type IGReaderBackend

type IGReaderBackend interface {

	// Login check username and password, return token
	Login(ctx context.Context, username, password string) (string, error)
	// Register register a new user
	Register(ctx context.Context, username, password string) error

	// ListTag list all tags
	ListTag(ctx context.Context, username string) ([]string, error)
	// RenameTag rename tag, from oldName to newName
	RenameTag(ctx context.Context, username, oldName, newName string) error
	// DeleteTag delete tag, and remove all subscription of this tag
	DeleteTag(ctx context.Context, username, name string) error

	// ListSubscription list all subscription
	ListSubscription(ctx context.Context, username string) ([]*Subscription, error)
	// AddSubscription add subscription
	AddSubscription(ctx context.Context, username string, feedURL, homeURL, title string) (*Subscription, error)
	// DeleteSubscription delete subscription
	DeleteSubscription(ctx context.Context, username string, feedID string) error
	// UpdateSubscriptionTitle update subscription's title
	UpdateSubscriptionTitle(ctx context.Context, username string, feedID, title string) error
	// UpdateSubscriptionTag update subscription's tag
	UpdateSubscriptionTag(ctx context.Context, username string, feedID string, addTag, removeTag string) error

	// ListEntryIDs list entry's id list
	ListEntryIDs(ctx context.Context, username string, readed, starred *bool, feedID *string, since time.Time, count int64, continuation string) (string, []int64, error)
	// UpdateEntry update entry's status
	UpdateEntry(ctx context.Context, username string, entryIDs []string, read, starred *bool) error
	// LoadEntry load entry by entry ids
	LoadEntry(ctx context.Context, username string, entryIDs []string) ([]*Entry, error)

	// ListFeedURL list all feed url
	ListFeedURL(ctx context.Context) ([]string, error)
	// AddFeedEntry add feed entry
	AddFeedEntry(ctx context.Context, username *string, feedURL string, entryList []*Entry) error
}

type ILogger

type ILogger interface {
	Info(ctx context.Context, format string, args ...interface{})
	Error(ctx context.Context, format string, args ...interface{})
}

func NewDefaultLogger

func NewDefaultLogger() ILogger

type Subscription

type Subscription struct {
	FeedID      string      `json:"id"`
	Name        string      `json:"title"`
	Categories  []*Category `json:"categories"`
	FeedURL     string      `json:"url"`
	HomePageURL string      `json:"htmlUrl"`
	IconURL     string      `json:"iconUrl"`
}

type Tag

type Tag struct {
	ID   string `json:"id,omitempty"`
	Type string `json:"type,omitempty"` // folder
}

Jump to

Keyboard shortcuts

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