http

package
v0.0.0-...-b8a6d4d Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONMiddleware

func JSONMiddleware(next http.Handler) http.Handler

func JWTAuth

func JWTAuth(original func(w http.ResponseWriter, r *http.Request)) func(w http.ResponseWriter, r *http.Request)

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func Requestor

func Requestor(token string) (string, error)

check uid from token

func TimeoutMiddleware

func TimeoutMiddleware(next http.Handler) http.Handler

func Verify

func Verify(token string) error

Verify checks if the token is valid or not

Types

type CreateUserRequest

type CreateUserRequest struct {
	UserName     string `json:"username" validate:"required"`
	PasswordHash string `json:"password" validate:"required"`
}

type ExerciseRequest

type ExerciseRequest struct {
	Name      string `json:"name"`
	Muscle    string `json:"muscle"`
	Equipment string `json:"equipment"`
}

type ExerciseResponse

type ExerciseResponse struct {
	Message string
}

type ExerciseService

type ExerciseService interface {
	GetExerciseByID(ctx context.Context, uid string) (exercise.Exercise, error)
	GetExerciseByName(ctx context.Context, name string) ([]exercise.Exercise, error)
	GetExerciseByMuscle(ctx context.Context, name string) ([]exercise.Exercise, error)
	GetExerciseByEquipment(ctx context.Context, equip string) ([]exercise.Exercise, error)
}

type HistoryRequest

type HistoryRequest struct {
	ID        string
	Date      string `json:"date"`
	Duration  string `json:"duration"`
	Notes     string `json:"notes"`
	PlanID    string `json:"plan_id"`
	AthleteID string `json:"athlete_id"`
}

type HistoryResponse

type HistoryResponse struct {
	Message string
}

type HistoryService

type HistoryService interface {
	CreateHistory(context.Context, history.History) error
	GetHistory(context.Context, string) ([]history.History, error)
	UpdateHistory(context.Context, history.History) error
	DeleteHistory(context.Context, string) error
}

type LoginRequest

type LoginRequest struct {
	UserName string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type Response

type Response struct {
	Message string
}

type SwoleHandler

type SwoleHandler struct {
	Router   *mux.Router
	UService UserService
	EService ExerciseService
	WService WorkoutService
	HService HistoryService
	Server   *http.Server
}

func NewHandler

func NewHandler(uservice UserService, eservice ExerciseService, wservice WorkoutService, hservice HistoryService) *SwoleHandler

func (*SwoleHandler) AuthZ

func (h *SwoleHandler) AuthZ(r *http.Request, OwnerID string) error

func (*SwoleHandler) CreateHistory

func (h *SwoleHandler) CreateHistory(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) CreateUser

func (h *SwoleHandler) CreateUser(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) CreateWorkout

func (h *SwoleHandler) CreateWorkout(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) DeleteHistory

func (h *SwoleHandler) DeleteHistory(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) DeleteUser

func (h *SwoleHandler) DeleteUser(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) DeleteWorkout

func (h *SwoleHandler) DeleteWorkout(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetExerciseByEquipment

func (h *SwoleHandler) GetExerciseByEquipment(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetExerciseByID

func (h *SwoleHandler) GetExerciseByID(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetExerciseByMuscle

func (h *SwoleHandler) GetExerciseByMuscle(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetExerciseByName

func (h *SwoleHandler) GetExerciseByName(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetHistory

func (h *SwoleHandler) GetHistory(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetUserByID

func (h *SwoleHandler) GetUserByID(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetUserByName

func (h *SwoleHandler) GetUserByName(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetWorkoutExercises

func (h *SwoleHandler) GetWorkoutExercises(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) GetWorkoutsByUser

func (h *SwoleHandler) GetWorkoutsByUser(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) Login

func (h *SwoleHandler) Login(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) Serve

func (h *SwoleHandler) Serve() error

func (*SwoleHandler) UpdateHistory

func (h *SwoleHandler) UpdateHistory(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) UpdateUserPassword

func (h *SwoleHandler) UpdateUserPassword(w http.ResponseWriter, r *http.Request)

func (*SwoleHandler) UpdateWorkout

func (h *SwoleHandler) UpdateWorkout(w http.ResponseWriter, r *http.Request)

type UserService

type UserService interface {
	CreateUser(ctx context.Context, username string, password string) (string, error)
	GetUserByID(ctx context.Context, uid string) (swoleuser.User, error)
	GetUserByName(ctx context.Context, username string) (swoleuser.User, error)
	UpdateUserPassword(ctx context.Context, uid string, password string) error
	DeleteUser(ctx context.Context, uid string) error
	Login(ctx context.Context, username string, password string) (string, error)
}

type WorkoutLineItem

type WorkoutLineItem struct {
	ID         string `json:"id"`
	Sets       string `json:"sets"`
	Reps       string `json:"reps"`
	Load       string `json:"load"`
	ExerciseID string `json:"exercise_id"`
}

type WorkoutPlanRequest

type WorkoutPlanRequest struct {
	UID       string            `json:"uid"`
	Name      string            `json:"name"`
	Exercises []WorkoutLineItem `json:"exercises"`
}

type WorkoutRequest

type WorkoutRequest struct {
	ID             string `json:"id"`
	PlanID         string `json:"plan_id"`
	Name           string `json:"name"`
	Sets           string `json:"sets"`
	Reps           string `json:"reps"`
	Load           string `json:"load"`
	CreatedAt      string `json:"created_at"`
	EditedAt       string `json:"edited_at"`
	CreatorID      string `json:"creator_id"`
	ExerciseID     string `json:"exercise_id"`
	InstructionsID string `json:"instructions_id"`
}

type WorkoutResponse

type WorkoutResponse struct {
	Message string
}

type WorkoutService

type WorkoutService interface {
	CreateWorkout(ctx context.Context, wo []workout.Workout) error
	GetWorkoutExercises(ctx context.Context, id string) ([]workout.WorkoutRow, error)
	GetWorkoutDetails(ctx context.Context, plan_id string) ([]workout.Workout, error)
	GetWorkoutsByUser(ctx context.Context, user string) ([]workout.WorkoutShortInfo, error)
	UpdateWorkout(ctx context.Context, wo []workout.Workout) error
	DeleteWorkout(ctx context.Context, id []string) error
}

Jump to

Keyboard shortcuts

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