utils

package
v0.0.0-...-a9a82f6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSessionKey

func GenerateSessionKey() (string, error)

func GetBearer

func GetBearer(r *http.Request) string

func GetInt32FromPath

func GetInt32FromPath(r *http.Request, key string) (int32, error)

func GetInt32FromQuery

func GetInt32FromQuery(r *http.Request, key string, defaultValue int32) int32

func GetPagination

func GetPagination(limit, page int32) (newLimit, offset int)

func GetSessionFromContext

func GetSessionFromContext(ctx context.Context) *entity.Session

func GetUserIDFromContext

func GetUserIDFromContext(ctx context.Context) int32

func HashBcrypt

func HashBcrypt(password string) (string, error)

func HashBcryptCompare

func HashBcryptCompare(password, hash string) bool

func HashSha256

func HashSha256(data string) string

func ParseJsonFromHTTPRequest

func ParseJsonFromHTTPRequest(r io.ReadCloser, data interface{}) error

func PrepareStringToLike

func PrepareStringToLike(s string) string

func Response

func Response(w http.ResponseWriter, respBody interface{}) error

func ResponseWithMeta

func ResponseWithMeta(w http.ResponseWriter, respBody interface{}, meta *Meta) error

func UUIDGenerate

func UUIDGenerate() (string, error)

Types

type JSONResponse

type JSONResponse struct {
	// Body
	Data interface{} `json:"data,omitempty"`
	// Meta
	Meta *Meta `json:"meta,omitempty"`
}

type Meta

type Meta struct {
	Total int32 `json:"total"`
	Limit int32 `json:"limit"`
	Page  int32 `json:"page"`
}

Jump to

Keyboard shortcuts

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