Documentation
¶
Index ¶
- func GetRemoteIP(r *http.Request) string
- func NewRouter(ua *UserAPI, fa *FeedAPI, rs *ReadStatusAPI, domain string) http.Handler
- type ErrorHandler
- type Feed
- type FeedAPI
- func (fa *FeedAPI) AddFeed(w http.ResponseWriter, r *http.Request) error
- func (fa *FeedAPI) AddFolder(w http.ResponseWriter, r *http.Request) error
- func (fa *FeedAPI) GetFeed(w http.ResponseWriter, r *http.Request) error
- func (fa *FeedAPI) GetFolders(w http.ResponseWriter, r *http.Request) error
- func (fa *FeedAPI) GetPost(w http.ResponseWriter, r *http.Request) error
- func (fa *FeedAPI) RemoveFeed(w http.ResponseWriter, r *http.Request) error
- type FeedStore
- type Folder
- type KeySigner
- type Mailer
- type MockMailer
- type Post
- type ReadStatusAPI
- type ReadStatusStore
- type Session
- type StdoutMailer
- type UserAPI
- func (ua *UserAPI) Activate(w http.ResponseWriter, r *http.Request) error
- func (ua *UserAPI) CreatePayment(w http.ResponseWriter, r *http.Request) error
- func (ua *UserAPI) Deactivate(w http.ResponseWriter, r *http.Request) error
- func (ua *UserAPI) DisableEmailVerification()
- func (ua *UserAPI) ListSessions(w http.ResponseWriter, r *http.Request) error
- func (ua *UserAPI) RequestToken(w http.ResponseWriter, r *http.Request) error
- func (ua *UserAPI) VerifyKey(w http.ResponseWriter, r *http.Request) error
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRemoteIP ¶
Types ¶
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request) error
ErrorHandler wraps up common error handling patterns for http routers
func (ErrorHandler) ServeHTTP ¶
func (eh ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Feed ¶
type Feed struct { ID string `json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Title string `json:"title"` Plugin string `json:"plugin"` BaseURL string `json:"base_url"` Unread int `json:"unread"` Posts []*Post `json:"posts"` }
A Feed is a collection of posts
type FeedAPI ¶
type FeedAPI struct {
// contains filtered or unexported fields
}
FeedAPI encapsulates everything related to user management
func NewFeedAPI ¶
func NewFeedAPI(s FeedStore, dc *discollect.Discollector, ks *KeySigner) *FeedAPI
NewFeedAPI returns a new Feed API
func (*FeedAPI) AddFeed ¶
AddFeed adds the specified feed to the given user if folder_id is left out, the feed is added to the users "default" folder
func (*FeedAPI) GetFolders ¶
GetFolders writes all of a users folders out
func (*FeedAPI) RemoveFeed ¶
RemoveFeed removes the given feed from the users list
type FeedStore ¶
type FeedStore interface { AddFeed(ctx context.Context, sessionKey, folderID, title, plugin, feedURL string, initConf *discollect.Config) (string, error) CheckIfFeedExists(ctx context.Context, sessionKey, folderID, plugin, url string) (*Feed, bool, error) RemoveFeed(ctx context.Context, sessionKey, folderID, feedID string) error AddFolder(ctx context.Context, sessionKey, name string) (string, error) // GetFolders should not return any Posts in the nested Feeds GetFoldersWithFeeds(ctx context.Context, sessionKey string) ([]*Folder, error) // Return Post Title, PostedAt, Read, and ID GetFeedPosts(ctx context.Context, sessionKey, feedID string, limit, offset int) (*Feed, error) GetPost(ctx context.Context, sessionKey, postID string) (*Post, error) }
A FeedStore is an interface used to seperate the FeedAPI from knowledge of the actual underlying database
type Folder ¶
type Folder struct { ID string `json:"id"` Title string `json:"title"` Feeds []*Feed `json:"feeds"` }
A Folder holds a collection of feeds
type KeySigner ¶
type KeySigner struct {
// contains filtered or unexported fields
}
A KeySigner is used to verify the integrity of SessionKeys at the system borders
func NewKeySigner ¶
NewKeySigner creates a new KeySigner with the given key
type MockMailer ¶
type MockMailer struct {
Mails []string
}
MockMailer is a fake mailer that records all mails sent
func (*MockMailer) RootDomain ¶
func (mm *MockMailer) RootDomain() string
RootDomain returns the MockMailer's rootdomain, always localhost TODO: this is probably broken
func (*MockMailer) Send ¶
func (mm *MockMailer) Send(email, subject, body string) error
Send stores a mail in the local MockMailer
type Post ¶
type Post struct { ID string `json:"id"` CreatedAt time.Time `json:"created_at"` PostedAt time.Time `json:"posted_at"` UpdatedAt time.Time `json:"updated_at"` // TODO(fortytw2): normalize this OriginalURL string `json:"original_url"` URL string `json:"url"` Title string `json:"title"` Author string `json:"author"` Body string `json:"body"` Read bool `json:"read"` Extra map[string]interface{} `json:"extra"` }
A Post is a single post on a feed
func (*Post) ContentHash ¶
ContentHash returns the stable hex encoded SHA256 of a post
type ReadStatusAPI ¶
type ReadStatusAPI struct {
// contains filtered or unexported fields
}
func NewReadStatusAPI ¶
func NewReadStatusAPI(s ReadStatusStore, ks *KeySigner) *ReadStatusAPI
NewReadStatusAPI returns a new Feed API
func (*ReadStatusAPI) MarkRead ¶
func (rs *ReadStatusAPI) MarkRead(w http.ResponseWriter, r *http.Request) error
MarkRead marks the given post as read
type ReadStatusStore ¶
ReadStatusStore tracks read_statuses
type Session ¶
type Session struct { CreatedAt time.Time `json:"created_at"` UserAgent string `json:"user_agent"` IP string `json:"ip"` Active bool `json:"active"` }
A Session is a session
type StdoutMailer ¶
type StdoutMailer struct {
Domain string
}
StdoutMailer writes all emails to Stdout, perfect for dev / debugging
func (*StdoutMailer) RootDomain ¶
func (sm *StdoutMailer) RootDomain() string
RootDomain returns the StdoutMailer root domain
func (*StdoutMailer) Send ¶
func (*StdoutMailer) Send(email, subject, body string) error
Send writes the email to stdout
type UserAPI ¶
type UserAPI struct {
// contains filtered or unexported fields
}
UserAPI encapsulates everything related to user management
func NewUserAPI ¶
func NewUserAPI(s UserStore, ks *KeySigner, m Mailer, stripePlanID, stripeKey string, paymentRequired bool) *UserAPI
NewUserAPI sets up a new UserAPI used for user/session management
func (*UserAPI) Activate ¶
Activate exchanges a token for a session key that can be used to make authenticated requests
func (*UserAPI) CreatePayment ¶
CreatePayment sets up the initial stripe stuff for a user
func (*UserAPI) Deactivate ¶
Deactivate disables a key that the user is currently using
func (*UserAPI) DisableEmailVerification ¶
func (ua *UserAPI) DisableEmailVerification()
func (*UserAPI) ListSessions ¶
ListSessions writes out all of a users current / past sessions
func (*UserAPI) RequestToken ¶
RequestToken emails a token that can be exchanged for a session
type UserStore ¶
type UserStore interface { // ensure the given session key exists VerifyKey(ctx context.Context, key string) error CreateOrGetUser(ctx context.Context, email string) (string, bool, error) SetStripeIDs(ctx context.Context, userID, customerID, subscriptionID string) error CreateLoginToken(ctx context.Context, userID, userAgent, ip string) (string, error) ActivateLoginToken(ctx context.Context, token string) (string, error) CreateSession(ctx context.Context, userID, userAgent, ip string) (string, string, error) ListSessions(ctx context.Context, key string, page int) ([]*Session, error) DeactivateSession(ctx context.Context, key string) error }
A UserStore is an interface used to seperate the UserAPI from knowledge of the actual underlying database
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
redis
package redis implements a lightweight queue on top of RPOPLPUSH for hydrocarbon to use
|
package redis implements a lightweight queue on top of RPOPLPUSH for hydrocarbon to use |
plugins
|
|
jsonfeed
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |