Documentation ¶
Index ¶
- Variables
- func ComparePassword(ctx context.Context, hash string, password string) error
- func GetContextRequesterID(ctx context.Context) uuid.UUID
- func HashPassword(ctx context.Context, password string) (string, error)
- func Init(lg *logging.Logger, db *sql.DB, cache *redis.Pool, opt InitOption)
- func NewSession(ctx context.Context, s Session) (string, error)
- func RespondError(w http.ResponseWriter, message string, status int)
- func SessionKey(token string) string
- func SetContextRequesterID(ctx context.Context, id uuid.UUID) context.Context
- func SetContextSession(ctx context.Context, session Session) context.Context
- func SetContextToken(ctx context.Context, token string) context.Context
- func SetRequesterContext(ctx context.Context, session Session) context.Context
- type BaseResponse
- type Error
- type InitOption
- type Response
- type Session
- type SessionData
- type SessionModule
- type UserDataParam
- type UserLoginParam
- type UserModule
- func (m UserModule) Create(ctx context.Context, param UserDataParam) (model.UserModelResponse, *Error)
- func (m UserModule) Delete(ctx context.Context, id uuid.UUID) *Error
- func (m UserModule) Detail(ctx context.Context, id uuid.UUID) (model.UserModelResponse, *Error)
- func (m UserModule) List(ctx context.Context) ([]model.UserModelResponse, *Error)
- func (m UserModule) Login(ctx context.Context, param UserLoginParam) (model.UserModelResponse, string, *Error)
- func (m UserModule) Register(ctx context.Context, param UserDataParam) (model.UserModelResponse, *Error)
- func (m UserModule) Update(ctx context.Context, param UserDataParam) *Error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MessageGeneralError = "Ada kesalahan, Silahakan coba beberapa saat lagi." MessageInvalidLogin = "Email atau password anda salah." MessageAccountExists = "Akun anda sudah terdaftar, silahkan login." )
View Source
var (
)Functions ¶
func ComparePassword ¶
func NewSession ¶
Create new session of given data.
func RespondError ¶
func RespondError(w http.ResponseWriter, message string, status int)
RespondError writes / respond with JSON-formatted request of given message & http status.
func SessionKey ¶
SessionKey return session cache's key with token parameter.
func SetContextRequesterID ¶
func SetContextSession ¶
Types ¶
type BaseResponse ¶
type BaseResponse struct {
Errors []string `json:"errors,omitempty"`
}
type InitOption ¶
type InitOption struct {
SessionExpire string
}
type Response ¶
type Response struct { Status string `json:"status"` BaseResponse `json:"errors"` Data interface{} `json:"result"` }
type Session ¶
type Session struct {
User model.UserModelResponse `json:"user"`
}
func GetSession ¶
GetSession returns session detail of given token string.
func (*Session) RequesterID ¶
Get current session data's identifier / id value.
type SessionData ¶
type SessionModule ¶
type SessionModule struct {
// contains filtered or unexported fields
}
type UserDataParam ¶
type UserLoginParam ¶
type UserModule ¶
type UserModule struct {
// contains filtered or unexported fields
}
func NewUserModule ¶
func NewUserModule(db *sql.DB, cache *redis.Pool) *UserModule
func (UserModule) Create ¶
func (m UserModule) Create(ctx context.Context, param UserDataParam) (model.UserModelResponse, *Error)
func (UserModule) Detail ¶
func (m UserModule) Detail(ctx context.Context, id uuid.UUID) (model.UserModelResponse, *Error)
func (UserModule) List ¶
func (m UserModule) List(ctx context.Context) ([]model.UserModelResponse, *Error)
func (UserModule) Login ¶
func (m UserModule) Login(ctx context.Context, param UserLoginParam) (model.UserModelResponse, string, *Error)
func (UserModule) Register ¶
func (m UserModule) Register(ctx context.Context, param UserDataParam) (model.UserModelResponse, *Error)
func (UserModule) Update ¶
func (m UserModule) Update(ctx context.Context, param UserDataParam) *Error
Click to show internal directories.
Click to hide internal directories.