Documentation ¶
Index ¶
- type Admin
- type Admins
- type Categories
- type Category
- type Comment
- type Comments
- type Config
- type Configs
- type JWT
- func (j *JWT) CreateAccessToken(id int) (string, error)
- func (j *JWT) CreateRefreshToken(id int) (string, error)
- func (j *JWT) ExtractAccessUUID(t *jwt.Token) (string, error)
- func (j *JWT) ExtractRefreshUUID(t *jwt.Token) (string, error)
- func (j *JWT) ExtractToken(bearToken string) string
- func (j *JWT) GetAccessUUID(verifiedToken *jwt.Token) (string, error)
- func (j *JWT) GetRefreshUUID(verifiedToken *jwt.Token) (string, error)
- func (j *JWT) GetVerifiedAccessToken(bearerToken string) (*jwt.Token, error)
- func (j *JWT) GetVerifiedRefreshToken(bearerToken string) (*jwt.Token, error)
- func (j *JWT) VerifyToken(token string, secret string) (*jwt.Token, error)
- type Logger
- type Post
- type Posts
- type Tag
- type Tags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct { ID int `json:"id"` Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
A Admin represents the singular of admin.
type Category ¶
type Category struct { ID int `json:"id"` Name string `json:"name"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
A Category represents the singular of category.
type Comment ¶
type Comment struct { ID int `json:"id"` PostID int `json:"post"` Body string `json:"body"` Status string `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
A Comment represents the singular of comment.
type Config ¶
type Config struct { ID int `json:"id"` Key string `json:"key"` Name string `json:"name"` Value string `json:"value"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
A Config represents the singular of config.
type JWT ¶
type JWT struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` AccessUUID string `json:"access_uuid"` RefreshUUID string `json:"refresh_uuid"` AtExpires int64 `json:"at_expires"` RtExpires int64 `json:"rt_expires"` }
A JWT represents the singular of jwt authentication.
func (*JWT) CreateAccessToken ¶
CreateAccessToken creates an access token.
func (*JWT) CreateRefreshToken ¶
CreateRefreshToken creates a refresh token.
func (*JWT) ExtractAccessUUID ¶
ExtractAccessUUID extract data from a verified token.
func (*JWT) ExtractRefreshUUID ¶
ExtractRefreshUUID extract data from a verified token.
func (*JWT) ExtractToken ¶
ExtractToken extract a token from authorization header in request. For example, if bearToken is "Bearer abcd.efgh.ijkl", return "abcd..efgh.ijkl"
func (*JWT) GetAccessUUID ¶
GetAccessUUID gets an access uuid from request Authorization header.
func (*JWT) GetRefreshUUID ¶
GetRefreshUUID gets an refresh uuid from request Authorization header.
func (*JWT) GetVerifiedAccessToken ¶
GetVerifiedAccessToken gets a verified token from a bearer token.
func (*JWT) GetVerifiedRefreshToken ¶
GetVerifiedRefreshToken gets a verified token from a bearer token.
func (*JWT) VerifyToken ¶
VerifyToken verifies jwt. See: https://godoc.org/github.com/dgrijalva/jwt-go#example-Parse--Hmac
type Logger ¶
type Logger interface { Error(string, ...any) ErrorContext(context.Context, string, ...any) Info(string, ...any) InfoContext(context.Context, string, ...any) }
A Logger is a logger interface.
type Post ¶
type Post struct { ID int `json:"id"` Admin Admin `json:"admin"` Category Category `json:"category"` Tags Tags `json:"tags"` Title string `json:"title"` MDBody string `json:"md_body"` HTMLBody string `json:"html_body"` Status string `json:"status"` Comments Comments `json:"comments"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
A Post represents the singular of post.