Documentation ¶
Index ¶
- func APIAuthHandler(next http.Handler) http.Handler
- func AccountHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func AccountsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func BackupHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func CreateRouter(s *Services) (*chi.Mux, error)
- func FaviconHandler(w http.ResponseWriter, r *http.Request)
- func HTMLLoginHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func HTMLRegisterHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func HTMLUserPageHandler(s *Services, templateName string) func(w http.ResponseWriter, r *http.Request)
- func LoginHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func LogoutHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func NoCacheHeaderMiddlewareFunc(next http.Handler) http.Handler
- func PageAuthHandler(next http.Handler) http.Handler
- func RegisterHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func ReportHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func RootHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func SettingsHandler(s *Services, maxUploadSize int64) func(w http.ResponseWriter, r *http.Request)
- func TagsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func TransactionHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func TransactionsCountHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- func TransactionsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
- type AuthHandler
- type DB
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIAuthHandler ¶
APIAuthHandler checks to see if the API is accessed by an authorized user, and returns an error if the request is done by an unauthorized user.
func AccountHandler ¶
func AccountHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
AccountHandler gets, updates or deletes an Account.
func AccountsHandler ¶
func AccountsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
AccountsHandler returns all Accounts for an authenticated user.
func BackupHandler ¶
func BackupHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
BackupHandler returns a serialized backup of all data for an authenticated user.
func CreateRouter ¶
CreateRouter returns a router and all handlers.
func FaviconHandler ¶
func FaviconHandler(w http.ResponseWriter, r *http.Request)
FaviconHandler serves the favicon.
func HTMLLoginHandler ¶
func HTMLLoginHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
HTMLLoginHandler serves the login page.
func HTMLRegisterHandler ¶
func HTMLRegisterHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
HTMLRegisterHandler serves the register page.
func HTMLUserPageHandler ¶
func HTMLUserPageHandler(s *Services, templateName string) func(w http.ResponseWriter, r *http.Request)
HTMLUserPageHandler serves a user-specific page.
func LoginHandler ¶
func LoginHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
LoginHandler authenticates the user and sets the encrypted session cookie if the user provided valid credentials.
func LogoutHandler ¶
func LogoutHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
LogoutHandler logs out the user.
func NoCacheHeaderMiddlewareFunc ¶
NoCacheHeaderMiddlewareFunc creates a handler to disable caching.
func PageAuthHandler ¶
PageAuthHandler checks to see if an HTML page is accessed by an authorized user, and redirects to the login page if the request is done by an unauthorized user.
func RegisterHandler ¶
func RegisterHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
RegisterHandler creates and logs in a new user.
func ReportHandler ¶
func ReportHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
ReportHandler generates data for a report.
func RootHandler ¶
func RootHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
RootHandler handles the root url. It redirects authenticated users to the default page and unauthenticated users to the login page.
func SettingsHandler ¶
SettingsHandler gets or updates settings for an authenticated user.
func TagsHandler ¶
func TagsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
TagsHandler returns a sorted, deduplicated list of tags for an authenticated user.
func TransactionHandler ¶
func TransactionHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
TransactionHandler gets, updates or deletes a Transaction.
func TransactionsCountHandler ¶
func TransactionsCountHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
TransactionsCountHandler returns the number of transactions for an authenticated user.
func TransactionsHandler ¶
func TransactionsHandler(s *Services) func(w http.ResponseWriter, r *http.Request)
TransactionsHandler returns a filtered, pages list of transactions for an authenticated user.
Types ¶
type AuthHandler ¶
type AuthHandler interface { SetCookieUsername(w http.ResponseWriter, username string, rememberMe bool) error AuthHandlerFunc(next http.Handler) http.Handler HasAuthenticationCookie(r *http.Request) bool }
AuthHandler handles authentication and authentication cookies.
type DB ¶
type DB interface { GetOrCreateConfigVariable(varName string, generator func() (string, error)) (string, error) GetUser(username string) (*data.User, error) SaveUser(*data.User) error GetAccounts(*data.User) ([]*data.Account, error) GetTransactions(*data.User, data.GetTransactionOptions) ([]*data.Transaction, error) CountTransactions(*data.User, data.TransactionFilterOptions) (uint64, error) CreateAccount(*data.User, *data.Account) error UpdateAccount(*data.User, *data.Account) error GetAccount(user *data.User, accountUUID string) (*data.Account, error) DeleteAccount(user *data.User, accountUUID string) error CreateTransaction(*data.User, *data.Transaction) error UpdateTransaction(*data.User, *data.Transaction) error GetTransaction(user *data.User, transactionUUID string) (*data.Transaction, error) DeleteTransaction(user *data.User, transactionUUID string) error GetTags(user *data.User) ([]string, error) Backup(user *data.User) (string, error) Restore(user *data.User, value string) error }
DB provides functions to read and write items in the database.