Documentation ¶
Index ¶
- Constants
- func ApiRouter() http.Handler
- func DbCreateItem(item *Item) error
- func DbCreateSource(source *Source) error
- func DbDeleteItem(item *Item) error
- func DbDeleteItemsBySource(sourceID int64) (int64, error)
- func DbDeleteSource(id int64) error
- func DbUpdateItem(item *Item) error
- func DbUpdateSource(source *Source) error
- func DbUpsertSourceItem(item *Item) (int64, error)
- func ErrInvalidRequest(err error) render.Renderer
- func ErrRender(err error) render.Renderer
- func FeedSourceCtx(next http.Handler) http.Handler
- func FlashMiddleware(next http.Handler) http.Handler
- func NewFeedSourceListResponse(sources []*Source) []render.Renderer
- func SetupDb(config *Config)
- func SetupHandler(c *Config) *chi.Mux
- type ChannelConfig
- type Config
- type CustomFeed
- type DatabaseConfig
- type ErrResponse
- type FeedSourceResponse
- type Fetcher
- type FetcherConfig
- type Item
- type ServerConfig
- type Source
- type SourceRequest
- type SqlStorage
- func (s *SqlStorage) CreateItem(item *Item) error
- func (s *SqlStorage) CreateSource(source *Source) error
- func (s *SqlStorage) DeleteItem(item *Item) error
- func (s *SqlStorage) DeleteItemsBySource(sourceID int64) (int64, error)
- func (s *SqlStorage) DeleteSource(id int64) error
- func (s *SqlStorage) GetItemsForCustomFeed(offset int, limit int) ([]Item, error)
- func (s *SqlStorage) GetSource(id int64) (Source, error)
- func (s *SqlStorage) GetSourceItems(sourceID int64, offset int, limit int) ([]Item, error)
- func (s *SqlStorage) ListSource() []Source
- func (s *SqlStorage) UpdateItem(item *Item) error
- func (s *SqlStorage) UpdateSource(source *Source) error
- func (s *SqlStorage) UpsertSourceItem(item *Item) (int64, error)
- type Storage
Constants ¶
View Source
const (
SESSION_NAME = "session"
)
Variables ¶
This section is empty.
Functions ¶
func DbCreateItem ¶
func DbCreateSource ¶
func DbDeleteItem ¶
func DbDeleteItemsBySource ¶
func DbDeleteSource ¶
func DbUpdateItem ¶
func DbUpdateSource ¶
func DbUpsertSourceItem ¶
func ErrInvalidRequest ¶
func SetupHandler ¶
Types ¶
type ChannelConfig ¶
type ChannelConfig struct { Title string `yaml:"title"` Description string `yaml:"description"` Category string `yaml:"category"` Link string `yaml:"link"` Author string `yaml:"author"` Copyright string `yaml:"copyright"` Email string `yaml:"email"` Language string `yaml:"language"` PermaLink string `yaml:"permalink"` FeedLink string `yaml:"feedlink"` Explicit string `yaml:"explicit"` CoverURL string `yaml:"cover-url"` TrackingPrefix string `yaml:"tracking-prefix"` }
ChannelConfig represents program configuration
type Config ¶
type Config struct { Channel ChannelConfig `yaml:"channel"` Database DatabaseConfig `yaml:"database"` Server ServerConfig `yaml:"server"` Fetcher FetcherConfig `yaml:"fetcher"` }
Config stores all configuration
type CustomFeed ¶
type CustomFeed struct { Title string Description string Permalink string CoverURL string Language string Date time.Time Entries []Item Author string }
CustomFeed represents template variables used for rendering RSS feed
type DatabaseConfig ¶
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrResponse renderer type for handling all sorts of errors.
In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
type FeedSourceResponse ¶
type FeedSourceResponse struct {
*Source
}
func NewFeedSourceResponse ¶
func NewFeedSourceResponse(source *Source) *FeedSourceResponse
func (*FeedSourceResponse) Render ¶
func (rd *FeedSourceResponse) Render(w http.ResponseWriter, r *http.Request) error
type Fetcher ¶
type Fetcher struct {
Config *Config
}
func NewFetcher ¶
func SetupFetcher ¶
func (Fetcher) UpdateFeed ¶
type FetcherConfig ¶
type Item ¶
type Item struct { ID int64 `json:"id"` FeedID int64 `json:"feedId"` GUID string `xorm:" varchar(200) not null" json:"guid"` Title string `xorm:" varchar(200) null" json:"title"` Description string `json:"description"` PubDate time.Time `json:"pubdate"` Raw string `json:"raw"` EnclosureUrl string `xorm:" varchar(200) null" json:"enclosureUrl"` Entry string `json:"entry"` }
Item represents an item in a feed
func ApplyEnclosurePrefix ¶
apply prefix to enclosure url
type ServerConfig ¶
type Source ¶
type Source struct { ID int64 `json:"id"` URL string `xorm:" varchar(200) not null" json:"url"` Slug string `xorm:" varchar(200) not null" json:"slug"` Name string `xorm:" varchar(200) not null" json:"name"` }
func DbGetSource ¶
func DbListSource ¶
func DbListSource() []Source
type SourceRequest ¶
type SqlStorage ¶
type SqlStorage struct {
// contains filtered or unexported fields
}
func SetupSqlStorage ¶
func SetupSqlStorage(config *Config) *SqlStorage
func (*SqlStorage) CreateItem ¶
func (s *SqlStorage) CreateItem(item *Item) error
func (*SqlStorage) CreateSource ¶
func (s *SqlStorage) CreateSource(source *Source) error
func (*SqlStorage) DeleteItem ¶
func (s *SqlStorage) DeleteItem(item *Item) error
func (*SqlStorage) DeleteItemsBySource ¶
func (s *SqlStorage) DeleteItemsBySource(sourceID int64) (int64, error)
func (*SqlStorage) DeleteSource ¶
func (s *SqlStorage) DeleteSource(id int64) error
func (*SqlStorage) GetItemsForCustomFeed ¶
func (s *SqlStorage) GetItemsForCustomFeed(offset int, limit int) ([]Item, error)
func (*SqlStorage) GetSourceItems ¶
func (*SqlStorage) ListSource ¶
func (s *SqlStorage) ListSource() []Source
func (*SqlStorage) UpdateItem ¶
func (s *SqlStorage) UpdateItem(item *Item) error
func (*SqlStorage) UpdateSource ¶
func (s *SqlStorage) UpdateSource(source *Source) error
func (*SqlStorage) UpsertSourceItem ¶
func (s *SqlStorage) UpsertSourceItem(item *Item) (int64, error)
type Storage ¶
type Storage interface { GetSource(id int64) (Source, error) ListSource() []Source CreateSource(source *Source) error UpdateSource(source *Source) error DeleteSource(id int64) error CreateItem(item *Item) error UpdateItem(item *Item) error DeleteItem(item *Item) error GetSourceItems(sourceID int64, offset int, limit int) ([]Item, error) UpsertSourceItem(item *Item) (int64, error) DeleteItemsBySource(sourceID int64) (int64, error) GetItemsForCustomFeed(offset int, limit int) ([]Item, error) }
Click to show internal directories.
Click to hide internal directories.