handler

package
v0.1.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvaildHash         = errors.New("the encoded hash is not in the correct format.")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)

Functions

func CheckRegexp

func CheckRegexp(reg, str string) bool

func GenerateJWTToken

func GenerateJWTToken(UserID string) (string, error)

func MakeErrorResponseBody

func MakeErrorResponseBody(statusCode int, detail string) []byte

Types

type Argon2Params

type Argon2Params struct {
	// contains filtered or unexported fields
}

type CreatePostParams

type CreatePostParams struct {
	Body string `json:"body" validate:"required"`
}

type ErrorPayload

type ErrorPayload struct {
	StatusCode string `json:"status_code"`
	Detail     string `json:"detail"`
}

type Handler

type Handler struct {
	DB       *sqlx.DB
	Validate *validator.Validate
}

func (*Handler) CheckUniqueEmail

func (h *Handler) CheckUniqueEmail(EMail string) (bool, error)

func (*Handler) CheckUniqueUserID

func (h *Handler) CheckUniqueUserID(UserID string) (bool, error)

func (*Handler) CreatePosts

func (h *Handler) CreatePosts(w http.ResponseWriter, r *http.Request)

func (*Handler) InsertPost

func (h *Handler) InsertPost(Claims jwt.MapClaims, requestData *CreatePostParams) error

func (*Handler) InsertUserData

func (h *Handler) InsertUserData(User *RegisterParams) error

func (*Handler) Login

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

func (*Handler) Register

func (h *Handler) Register(w http.ResponseWriter, r *http.Request)

func (*Handler) RoadPasswordAndUserID

func (h *Handler) RoadPasswordAndUserID(RequestUserID string) (string, string, error)

func (*Handler) UpdateAt

func (h *Handler) UpdateAt(RequestUserID string) error

type LoginParams

type LoginParams struct {
	UserName string `json:"userid" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type LoginResponseBody

type LoginResponseBody struct {
	Token string
}

type RegisterParams

type RegisterParams struct {
	UserID     string `json:"userid" validate:"required,min=1,max=15"`
	EMail      string `json:"email" validate:"required,email"`
	ScreenName string `json:"screen_name" validate:"required,max=50"`
	Password   string `json:"password" validate:"required"`
}

Jump to

Keyboard shortcuts

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