Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllRoutes ¶
Represents all possible Routes starting from source
func (*AllRoutes) GetViewModel ¶
func (r *AllRoutes) GetViewModel() interface{}
Returns the View Model of AllRoutes
func (*AllRoutes) SortByDistance ¶
func (r *AllRoutes) SortByDistance()
Sorts the RoutesInfo array by Distance
func (*AllRoutes) SortByDuration ¶
func (r *AllRoutes) SortByDuration()
Sorts the RoutesInfo array by duration
type Model ¶
type Model interface {
GetViewModel() interface{}
}
GetViewModel will be called before the model is sent for modifying the content of the model
type NewUser ¶
type NewUser struct { Username string `json:"username"` Password string `json:"password"` Role string `json:"role"` }
NewUser represents the user sent by the client as http request body TODO should be renamed
type RouteInfo ¶
type RouteInfo struct { Destination string `json:"destination"` Duration float64 `json:"duration"` Distance float64 `json:"distance"` }
Represents the Information about the Route
type User ¶
type User struct { gorm.Model Username string `gorm:"column:username;unique;not null"` Role string `gorm:"column:role,default:USER"` Password string `gorm:"column:password;not null"` }
User represents the model of the users table also includes the following fields: ID, CreatedAt, UpdatedAt, DeletedAt. Note Table name is users
func (*User) BeforeSave ¶
BeforeSave Hash the password before saving to the database
func (*User) BeforeUpdate ¶
BeforeSave Hash the password before update to the database NOTE this function will be called by the GORM before update
func (*User) CheckPasswordHash ¶
CheckPasswordHash checks whether the given password is correct or not Returns true if password matchs else false
func (*User) GenerateJWT ¶
GenerateJWT generates JWT token to be used for auth
func (*User) GetViewModel ¶
func (u *User) GetViewModel() interface{}
GetViewModel get Executed before the object get sent to the client Returns The User's View Model