Documentation ¶
Index ¶
- func Authenticate(next http.Handler) http.Handler
- func CompanyOverview(ticker string, client pb.WatcherClient) (*data.MoreStock, error)
- func Info(ticker, destination string, client pb.WatcherClient) (*data.Stock, error)
- func ReadEnvVar(key string) (string, error)
- type Claims
- type ControlHandler
- func (c *ControlHandler) Cache(next http.Handler) http.Handler
- func (c *ControlHandler) CreatePortfolio(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) CreateSecurity(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) DeletePortfolio(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) DeleteSecurity(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) GetAll(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) GetInfo(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) GetPortfolio(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) LogIn(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) LogOut(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) Logger(next http.Handler) http.Handler
- func (c *ControlHandler) MoreInfo(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) ReadSecurity(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) Refresh(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) SignUp(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) UpdatePortfolio(w http.ResponseWriter, r *http.Request)
- func (c *ControlHandler) UpdateSecurity(w http.ResponseWriter, r *http.Request)
- type IsAdmin
- type NamePair
- type Portfolio
- type Profits
- type ResponseMessage
- type STLKERModel
- type Security
- type User
- type Username
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompanyOverview ¶
MoreInfo returns a pointer to a MoreStock struct and an error if one arises
func ReadEnvVar ¶
ReadEnvVar reads an environmental variable specified by key after loading vars.env
Types ¶
type Claims ¶
type Claims struct { Name string `json:"Name"` Admin bool `json:"Admin"` jwt.StandardClaims }
type ControlHandler ¶
type ControlHandler struct {
// contains filtered or unexported fields
}
ControlHandler is a http.Handler
func NewControlHandler ¶
func NewControlHandler(log *log.Logger, wc pb.WatcherClient, rOptions *redis.Ring) *ControlHandler
NewControlHandler is a constructor
func (*ControlHandler) Cache ¶
func (c *ControlHandler) Cache(next http.Handler) http.Handler
Cache is a middleware that checks if a user cached their portfolio's profits in the past 15 minutes
func (*ControlHandler) CreatePortfolio ¶
func (c *ControlHandler) CreatePortfolio(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) CreateSecurity ¶
func (c *ControlHandler) CreateSecurity(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) DeletePortfolio ¶
func (c *ControlHandler) DeletePortfolio(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) DeleteSecurity ¶
func (c *ControlHandler) DeleteSecurity(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) GetAll ¶
func (c *ControlHandler) GetAll(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) GetInfo ¶
func (c *ControlHandler) GetInfo(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) GetPortfolio ¶
func (c *ControlHandler) GetPortfolio(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) LogIn ¶
func (c *ControlHandler) LogIn(w http.ResponseWriter, r *http.Request)
LogIn handles requests to /login and creates JWTs for valid users
func (*ControlHandler) LogOut ¶
func (c *ControlHandler) LogOut(w http.ResponseWriter, r *http.Request)
LogOut deletes the token cookie
func (*ControlHandler) MoreInfo ¶
func (c *ControlHandler) MoreInfo(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) ReadSecurity ¶
func (c *ControlHandler) ReadSecurity(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) Refresh ¶
func (c *ControlHandler) Refresh(w http.ResponseWriter, r *http.Request)
Refresh handles requests to /refresh and regenerates tokens if the current token is within a minute of expiry
func (*ControlHandler) SignUp ¶
func (c *ControlHandler) SignUp(w http.ResponseWriter, r *http.Request)
SignUp handles requests to /signup and adds new users to the db
func (*ControlHandler) UpdatePortfolio ¶
func (c *ControlHandler) UpdatePortfolio(w http.ResponseWriter, r *http.Request)
func (*ControlHandler) UpdateSecurity ¶
func (c *ControlHandler) UpdateSecurity(w http.ResponseWriter, r *http.Request)
type Portfolio ¶
type Portfolio struct { STLKERModel // Name is the name of the portfolio Name string `json:"Name"` Username string `json:"Username"` // Stocks is a slice of Security structs Securities []*Security `json:"Securities" gorm:"foreignKey:PortfolioID"` }
A Portfolio is a GORM model that is intended to mirror the structure of a simple portfolio
type ResponseMessage ¶
type ResponseMessage struct {
Msg string `json:"Message"`
}
type STLKERModel ¶
type Security ¶
type Security struct { STLKERModel SecurityID int `gorm:"primary_key" json:"-"` Ticker string `json:"Ticker"` BoughtPrice float64 `json:"Bought Price"` CurrPrice float64 `json:"Current Price"` Gain float64 `json:"Gain"` Change string `json:"Percent Change"` // Currency is the destination currency of the stock Currency string `json:"Currency" gorm:"default:USD"` // Foreign key PortfolioID uint `json:"-"` }