server

package
v0.0.0-...-5472ab2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIAuthHandler

func APIAuthHandler(next http.Handler) http.Handler

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

func CreateRouter(s *Services) (*chi.Mux, error)

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

func NoCacheHeaderMiddlewareFunc(next http.Handler) http.Handler

NoCacheHeaderMiddlewareFunc creates a handler to disable caching.

func PageAuthHandler

func PageAuthHandler(next http.Handler) http.Handler

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

func SettingsHandler(s *Services, maxUploadSize int64) func(w http.ResponseWriter, r *http.Request)

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.

type Services

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

Services keeps references to all services needed by handlers.

func CreateServices

func CreateServices(db *data.DBService) (*Services, error)

CreateServices creates a Services instance with db and default implementations of other services.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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