/
handler.go
47 lines (43 loc) · 1.1 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package handler
import (
"errors"
"github.com/jmoiron/sqlx"
"gopkg.in/go-playground/validator.v9"
)
type (
Handler struct {
DB *sqlx.DB
Validate *validator.Validate
}
Argon2Params struct {
memory uint32
iterations uint32
parallelism uint8
saltLength uint32
keyLength uint32
}
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"`
}
LoginParams struct {
UserName string `json:"userid" validate:"required"`
Password string `json:"password" validate:"required"`
}
CreatePostParams struct {
Body string `json:"body" validate:"required"`
}
ErrorPayload struct {
StatusCode string `json:"status_code"`
Detail string `json:"detail"`
}
LoginResponseBody struct {
Token string
}
)
var (
ErrInvaildHash = errors.New("the encoded hash is not in the correct format.")
ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)