common

package module
v0.0.0-...-bbf8f3e Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AuthHeaderKey        = "Authorization"
	AuthHeaderBearerType = "bearer"
)

Variables

This section is empty.

Functions

func DeserializeRequest

func DeserializeRequest(b []byte) (*http.Request, error)

func DeserializeResponse

func DeserializeResponse(b []byte) (*http.Response, error)

func GetEnv

func GetEnv(key, fallback string) string

func GetEnvBool

func GetEnvBool(key string, fallback bool) bool

func SerializeRequest

func SerializeRequest(req *http.Request) ([]byte, error)

func SerializeResponse

func SerializeResponse(resp *http.Response) ([]byte, error)

Types

type LoginResponse

type LoginResponse struct {
	AccessToken string `json:"access_token"`
	Username    string `json:"username"`
}

type LoginUserParams

type LoginUserParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type PasetoMaker

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

func NewPaseto

func NewPaseto(symmetricKey string) (*PasetoMaker, error)

func (*PasetoMaker) CreateToken

func (p *PasetoMaker) CreateToken(id string, duration time.Duration) (string, error)

func (*PasetoMaker) VerifyToken

func (p *PasetoMaker) VerifyToken(token string) (*TokenPayload, error)

type RegisterUserParams

type RegisterUserParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Email    string `json:"email"`
}

type TokenPayload

type TokenPayload struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	ExpiryAt  time.Time `json:"expiryAt"`
}

func NewPayload

func NewPayload(id string, duration time.Duration) *TokenPayload

func (*TokenPayload) Valid

func (p *TokenPayload) Valid() error

Jump to

Keyboard shortcuts

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