Documentation ¶
Index ¶
- type LoginForm
- type RestApi
- func (h *RestApi) DeleteHandler(w http.ResponseWriter, r *http.Request)
- func (h *RestApi) LoginHandler(w http.ResponseWriter, r *http.Request)
- func (h *RestApi) RegisterHandler(w http.ResponseWriter, r *http.Request)
- func (h *RestApi) ShowAllHandler(w http.ResponseWriter, r *http.Request)
- func (h *RestApi) UpdateHandler(w http.ResponseWriter, r *http.Request)
- type SignupForm
- type User
- type UserService
- type UserStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RestApi ¶
type RestApi struct { Routes routes.ApiRestRouteSet // contains filtered or unexported fields }
func NewRestApi ¶
func NewRestApi(userSvc UserService) RestApi
func (*RestApi) DeleteHandler ¶
func (h *RestApi) DeleteHandler(w http.ResponseWriter, r *http.Request)
func (*RestApi) LoginHandler ¶
func (h *RestApi) LoginHandler(w http.ResponseWriter, r *http.Request)
func (*RestApi) RegisterHandler ¶
func (h *RestApi) RegisterHandler(w http.ResponseWriter, r *http.Request)
func (*RestApi) ShowAllHandler ¶
func (h *RestApi) ShowAllHandler(w http.ResponseWriter, r *http.Request)
func (*RestApi) UpdateHandler ¶
func (h *RestApi) UpdateHandler(w http.ResponseWriter, r *http.Request)
type SignupForm ¶
type UserService ¶
type UserService interface { Authenticate(email, password string) (*tokens.JWTToken, error) Register(name, email, password string) (*User, error) GetByID(id uint) (*User, error) }
UserService
func NewUserService ¶
func NewUserService(store UserStore) UserService
type UserStore ¶
type UserStore interface { GetByID(int uint) (*User, error) GetByEmail(email string) (*User, error) Create(user *User) error // Close is used for closing the connection(s) to the store (database). Close() // AutoMigrate is a helper method used for database migration Migrate() error }
UserStore is used for interacting with the persistence layer for users, and it is the contract (interface) to used by outside package components. For all `Get_` methods, it either returns the user that is found and a nil error, or an error that is either defined by the `models` package (such as `ErrNotFound`) or another, more low level error.
func NewUserStore ¶
Click to show internal directories.
Click to hide internal directories.