Documentation ¶
Overview ¶
Package newsd implements the backend of newsd.
Index ¶
- Constants
- Variables
- type Engine
- func (e *Engine) FetchFavicon(ctx context.Context, u string, ifModifiedSince time.Time) (database.Favicon, error)
- func (e *Engine) FetchUrl(ctx context.Context, url string, opts ...FetchOptions) (*http.Response, error)
- func (e *Engine) SaveFavicon(ctx context.Context, u string) error
- func (e *Engine) UpdateChannel(ctx context.Context, user int64, u string) (database.Channel, error)
- type FetchOptions
Constants ¶
View Source
const ( ErrNotModified httpError = 304 ErrNotFound httpError = 404 ErrNotAcceptable httpError = 406 )
Variables ¶
View Source
var ( // DatabasePath is the path to the database. // In the future I would like to add PostgreSQL support so this may be // deprecated. DatabasePath = "./newsd.db" // CheckEvery specifies the interval to check for feeds that need to be // updated. CheckEvery = time.Minute * 15 // WorkerSize is the amount of free web workers for fetching feeds. WorkerSize = runtime.NumCPU() * 2 // QueueSize is the amount of channels that can be enqueued for update // at once. QueueSize = 1000 )
Configuration section. This is to be configured by cmd/newsd.
View Source
var ( // UserAgent is the user agent that is used to connect to web servers. // It should identify us in some way. UserAgent = "newsd/%s go/%s" )
Functions ¶
This section is empty.
Types ¶
type Engine ¶
func (*Engine) FetchFavicon ¶
func (e *Engine) FetchFavicon(ctx context.Context, u string, ifModifiedSince time.Time) (database.Favicon, error)
FetchFavicon attemps to find a favicon of a given URL.
The URL given is merely a hint; it will be tried first, but if an icon is unable to be found, /favicon.ico and / are tried to find the actual favicon path.
func (*Engine) FetchUrl ¶
func (e *Engine) FetchUrl(ctx context.Context, url string, opts ...FetchOptions) (*http.Response, error)
FetchUrl fetches a URL and returns an error if the response code is not 200.
If the response code is 304, errNotModified is returned.
If err is nil, the response is returned as is. It is up to the caller to handle closing the response body.
Click to show internal directories.
Click to hide internal directories.