handler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 15 Imported by: 0

README

ハンドラー層

  • クライアントから送られてきたデータのバリデーションを行う
  • 実際の処理(ユースケース)の依頼はサービス層に依頼
  • クライアントにステータスなどを含めた適切なデータ返す

ファイル

service.go
  • ハンドラー層とサービス層を繋げるインターフェースを記述する(依存関係の逆転)
  • より上位レベルにインターフェースを持たせる必要があるためハンドラー層に配置
  • ハンドラー層は必ずインターフェースを利用してサービス層を操作すること
response.go
  • レスポンスを作成するメソッド

middleware.go

  • カスタムミドルウェアを記述する

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIResponse

func APIResponse(ctx *gin.Context, StatusCode int, Message string, Data interface{})

APIレスポンスの作成(成功時)

@params ctx ginのコンテキスト StatusCode ステータスコード Message メッセージ Data 返却するデータ

func AuthMiddleware

func AuthMiddleware(j *auth.JWTer) gin.HandlerFunc

認証ミドルウェア

func ErrResponse

func ErrResponse(ctx *gin.Context, StatusCode int, Title, Message string, Err error)

エラーレスポンス作成

@params ctx ginのコンテキスト StatusCode ステータスコード Title エラータイトル Message メッセージ

Types

type DeleteUser

type DeleteUser struct {
	Service DeleteUserService
}

func NewDeleteUser

func NewDeleteUser(s DeleteUserService) *DeleteUser

func (*DeleteUser) ServeHTTP

func (du *DeleteUser) ServeHTTP(ctx *gin.Context)

ユーザー削除取得ハンドラー

@param ctx ginContext

type DeleteUserService

type DeleteUserService interface {
	DeleteUser(ctx *gin.Context, userID model.UserID) error
}

type ErrRes

type ErrRes struct {
	StatusCode int    `json:"statusCode"`
	Title      string `json:"title"`
	Message    string `json:"message"`
}

エラーのレスポンスの型

type GetAccount

type GetAccount struct {
	Service GetAccountService
}

func NewGetAccount

func NewGetAccount(s GetAccountService) *GetAccount

func (*GetAccount) ServeHTTP

func (gu *GetAccount) ServeHTTP(ctx *gin.Context)

ユーザ取得ハンドラー

@param ctx ginContext

type GetAccountService

type GetAccountService interface {
	GetAccount(ctx *gin.Context) (service.GetAccountResponse, error)
}

type GetNotification

type GetNotification struct {
	Service GetNotificationService
}

func NewGetNotification

func NewGetNotification(s GetNotificationService) *GetNotification

func (*GetNotification) ServeHTTP

func (gn *GetNotification) ServeHTTP(ctx *gin.Context)

お知らせ詳細取得ハンドラー

@param ctx ginContext

type GetNotificationService

type GetNotificationService interface {
	GetNotification(ctx *gin.Context, notificationID model.NotificationID) (service.GetNotificationResponse, error)
}

type GetNotifications

type GetNotifications struct {
	Service GetNotificationsService
}

func (*GetNotifications) ServeHTTP

func (gn *GetNotifications) ServeHTTP(ctx *gin.Context)

お知らせ一覧取得ハンドラー

@param ctx ginContext

type GetNotificationsService

type GetNotificationsService interface {
	GetNotifications(ctx *gin.Context, nextToken, size string) (service.GetNotificationsResponse, error)
}

type GetUncheckedNotificationCount

type GetUncheckedNotificationCount struct {
	Service GetUncheckedNotificationCountService
}

func (*GetUncheckedNotificationCount) ServeHTTP

func (gunc *GetUncheckedNotificationCount) ServeHTTP(ctx *gin.Context)

お知らせ数取得ハンドラー

@param ctx ginContext

type GetUncheckedNotificationCountService

type GetUncheckedNotificationCountService interface {
	GetUncheckedNotificationCount(ctx *gin.Context) (<-chan int, error)
}

type GetUsers

type GetUsers struct {
	Service GetUsersService
}

func NewGetUsers

func NewGetUsers(s GetUsersService) *GetUsers

func (*GetUsers) ServeHTTP

func (gu *GetUsers) ServeHTTP(ctx *gin.Context)

ユーザ一覧取得ハンドラー

@param ctx ginContext

type GetUsersService

type GetUsersService interface {
	GetUsers(ctx context.Context, input service.GetUsersRequest) (service.GetUsersResponse, error)
}

type HealthCheck

type HealthCheck struct{}

func NewHealthCheckHandler

func NewHealthCheckHandler() *HealthCheck

func (*HealthCheck) ServeHTTP

func (hc *HealthCheck) ServeHTTP(ctx *gin.Context)

type RegisterTemporaryUser

type RegisterTemporaryUser struct {
	Service RegisterTemporaryUserService
}

func (*RegisterTemporaryUser) ServeHTTP

func (ru *RegisterTemporaryUser) ServeHTTP(ctx *gin.Context)

ユーザ仮登録ハンドラー

@param ctx ginContext

type RegisterTemporaryUserService

type RegisterTemporaryUserService interface {
	RegisterTemporaryUser(ctx context.Context, firstName, firstNameKana, familyName, familyNameKana, email, password string) (string, error)
}

type RegisterUser

type RegisterUser struct {
	Service RegisterUserService
}

func NewRegisterUserHandler

func NewRegisterUserHandler(s RegisterUserService) *RegisterUser

func (*RegisterUser) ServeHTTP

func (ru *RegisterUser) ServeHTTP(ctx *gin.Context)

ユーザ本登録ハンドラー

@param ctx ginContext

type RegisterUserService

type RegisterUserService interface {
	RegisterUser(ctx context.Context, temporaryUserId, confirmCode string) (*entities.User, string, error)
}

type ResetPassword

type ResetPassword struct {
	Service ResetPasswordService
}

func NewResetPasswordHandler

func NewResetPasswordHandler(s ResetPasswordService) *ResetPassword

func (*ResetPassword) ServeHTTP

func (s *ResetPassword) ServeHTTP(ctx *gin.Context)

サインアウトハンドラー

@param ctx ginContext

type ResetPasswordService

type ResetPasswordService interface {
	ResetPassword(ctx context.Context, email string) error
}

type Responses

type Responses struct {
	StatusCode int         `json:"statusCode"`
	Message    string      `json:"message"`
	Data       interface{} `json:"data"`
}

クライアントへの返すレスポンスの型

type SendPoint

type SendPoint struct {
	Service SendPointService
}

func NewSendPoint

func NewSendPoint(s SendPointService) *SendPoint

func (*SendPoint) ServeHTTP

func (sp *SendPoint) ServeHTTP(ctx *gin.Context)

ポイント送付ハンドラー

@param ctx ginContext

type SendPointService

type SendPointService interface {
	SendPoint(ctx *gin.Context, toUserId, sendPoint int) error
}

type Signin

type Signin struct {
	Service SigninService
}

func NewSigninHandler

func NewSigninHandler(s SigninService) *Signin

func (*Signin) ServeHTTP

func (ru *Signin) ServeHTTP(ctx *gin.Context)

サインインハンドラー

@param ctx ginContext

type SigninService

type SigninService interface {
	Signin(ctx context.Context, email, password string) (string, error)
}

type Signout

type Signout struct {
	Service SignoutService
}

func NewSignoutHandler

func NewSignoutHandler(s SignoutService) *Signout

func (*Signout) ServeHTTP

func (s *Signout) ServeHTTP(ctx *gin.Context)

サインアウトハンドラー

@param ctx ginContext

type SignoutService

type SignoutService interface {
	Signout(ctx *gin.Context) error
}

type UpdateAccount

type UpdateAccount struct {
	Service UpdateAccountService
}

func NewUpdateAccountHandler

func NewUpdateAccountHandler(s UpdateAccountService) *UpdateAccount

func (*UpdateAccount) ServeHTTP

func (ua *UpdateAccount) ServeHTTP(ctx *gin.Context)

アカウント情報更新ハンドラー

@param ctx ginContext

type UpdateAccountService

type UpdateAccountService interface {
	UpdateAccount(ctx *gin.Context, familyName, familyNameKana, firstName, firstNameKana string) error
}

type UpdateEmail

type UpdateEmail struct {
	Service UpdateEmailService
}

func NewUpdateEmailHandler

func NewUpdateEmailHandler(s UpdateEmailService) *UpdateEmail

func (*UpdateEmail) ServeHTTP

func (ue *UpdateEmail) ServeHTTP(ctx *gin.Context)

メール本登録ハンドラー

@param ctx ginContext @return APIレスポンス結果

type UpdateEmailService

type UpdateEmailService interface {
	UpdateEmail(ctx *gin.Context, temporaryEmailID, confirmCode string) error
}

type UpdatePassword

type UpdatePassword struct {
	Service UpdatePasswordService
}

func NewUpdatePasswordHandler

func NewUpdatePasswordHandler(s UpdatePasswordService) *UpdatePassword

func (*UpdatePassword) ServeHTTP

func (rt *UpdatePassword) ServeHTTP(ctx *gin.Context)

パスワード更新ハンドラー

@param ctx ginContext

type UpdatePasswordService

type UpdatePasswordService interface {
	UpdatePassword(ctx *gin.Context, oldPassword, newPassword string) error
}

type UpdateTemporaryEmail

type UpdateTemporaryEmail struct {
	Service UpdateTemporaryEmailService
}

func (*UpdateTemporaryEmail) ServeHTTP

func (ute *UpdateTemporaryEmail) ServeHTTP(ctx *gin.Context)

メール仮登録ハンドラー

@param ctx ginContext

type UpdateTemporaryEmailService

type UpdateTemporaryEmailService interface {
	UpdateTemporaryEmail(ctx *gin.Context, email string) (string, error)
}

Jump to

Keyboard shortcuts

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