Documentation ¶
Index ¶
- func AdminMiddleware(next http.Handler) http.Handler
- func AuthMiddleware(j *auth.JWTer) func(next http.Handler) http.Handler
- func RespondJSON(ctx context.Context, w http.ResponseWriter, body any, status int)
- type AddExercise
- type AddExerciseService
- type DeleteExercise
- type DeleteExerciseService
- type ErrResponse
- type GetExercise
- type GetExerciseService
- type ListExercise
- type ListExercisesService
- type Login
- type LoginService
- type RegisterUser
- type RegisterUserService
- type UpdateExercise
- type UpdateExerciseService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
リクエストスコープな値(ユーザーID、ロール)をcontextへ埋め込む アクセストークンがない場合はリクエストの処理が終了させる
func RespondJSON ¶
JSONのレスポンスを書き込むヘルパー
Types ¶
type AddExercise ¶
type AddExercise struct { Service AddExerciseService Validator *validator.Validate }
func (*AddExercise) ServeHTTP ¶
func (ae *AddExercise) ServeHTTP(w http.ResponseWriter, r *http.Request)
リクエストボディを読み込み、バリデーション 結果が正常ならエクササイズを作成し、保存する レスポンスボディにRDBMSにより発行されたIDを書き込む
type AddExerciseService ¶
type DeleteExercise ¶
type DeleteExercise struct { Service DeleteExerciseService *GetExercise }
func (*DeleteExercise) ServeHTTP ¶
func (de *DeleteExercise) ServeHTTP(w http.ResponseWriter, r *http.Request)
type DeleteExerciseService ¶
type DeleteExerciseService interface {
DeleteExercise(ctx context.Context, id entity.ExerciseID) error
}
type ErrResponse ¶
type ErrResponse struct { Message string `json:"message"` Details []string `json:"details,omitempty"` }
統一したJSONフォーマットでエラーを返すための型
type GetExercise ¶
type GetExercise struct {
Service GetExerciseService
}
func (*GetExercise) ServeHTTP ¶
func (ge *GetExercise) ServeHTTP(w http.ResponseWriter, r *http.Request)
type GetExerciseService ¶
type ListExercise ¶
type ListExercise struct {
Service ListExercisesService
}
func (*ListExercise) ServeHTTP ¶
func (le *ListExercise) ServeHTTP(w http.ResponseWriter, r *http.Request)
DBから一覧を取得し、レスポンスボディに書き込む
type ListExercisesService ¶
type Login ¶
type Login struct { Service LoginService Validator *validator.Validate }
type LoginService ¶
type RegisterUser ¶
type RegisterUser struct { Service RegisterUserService Validator *validator.Validate }
func (*RegisterUser) ServeHTTP ¶
func (ru *RegisterUser) ServeHTTP(w http.ResponseWriter, r *http.Request)
type RegisterUserService ¶
type UpdateExercise ¶
type UpdateExercise struct { Service UpdateExerciseService Validator *validator.Validate *GetExercise }
func (*UpdateExercise) ServeHTTP ¶
func (ue *UpdateExercise) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UpdateExerciseService ¶
Click to show internal directories.
Click to hide internal directories.