config

package
v0.0.0-...-7e2adfa Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App() *config

func ComparePassword

func ComparePassword(hashedPassword, password string) bool

func ContainsElement

func ContainsElement(val interface{}, array interface{}) bool

ContainsElement checks if a value exists in a slice.

func CustomCronValidate

func CustomCronValidate()

The Go Playground Validator has a “cron” validation mechanism, but it does not work correctly. So we will validate with “robfig/cron parser”.

func CustomNoEmptyValidate

func CustomNoEmptyValidate()

The Go Playground Validator package does not have a validation tag that directly checks whether slices are empty. In the case of slices, this tag checks if the slice itself exists, but does not check if the contents of the slice are empty. We have written a special validation function to check if slices are empty.

func CustomValidate

func CustomValidate()

custom validates are called in main

func DecrementRunning

func DecrementRunning()

func GenerateToken

func GenerateToken(userId int) (string, error)

GenerateToken token generate

func GetUserIDByToken

func GetUserIDByToken(token string) (string, error)

func HasPrefixInList

func HasPrefixInList(str string, prefixes []string) bool

HasPrefixInList is a prefix checker

func HashAndSalt

func HashAndSalt(password string) string

func IncrementRunning

func IncrementRunning()

func LoadSQLQueries

func LoadSQLQueries() (map[string]string, error)

LoadSQLQueries loads SQL queries from a file and populates the QUERY map.

func RandomHex

func RandomHex(length int) string

func RandomString

func RandomString(length int) string

func ReadJSON

func ReadJSON(w http.ResponseWriter, r *http.Request, data any) error

func Render

func Render(w http.ResponseWriter, page string, data map[string]any, partials ...string) error

func ShuttingWrapper

func ShuttingWrapper(fn func())

func Validate

func Validate(structure any) error

func ValidateToken

func ValidateToken(token string) (*jwt.Token, error)

ValidateToken token validate

func WriteJSON

func WriteJSON(w http.ResponseWriter, httpStatus int, data Response, headers ...http.Header) error

Types

type CKey

type CKey string

context key type

type DB

type DB struct {
	*sql.DB
}

func (*DB) CloseDatabase

func (db *DB) CloseDatabase()

CloseDatabase method is closing a connection between your app and your db

func (*DB) ConnectDatabase

func (db *DB) ConnectDatabase()

ConnectDatabase is creating a new connection to our database

func (*DB) RunPrepare

func (db *DB) RunPrepare(exec any, query string, args ...any) (*sql.Stmt, error)

type ES

type ES struct {
	*elasticsearch.Client
}

type Kraft

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

func (*Kraft) Close

func (k *Kraft) Close()

Close closes the Kafka producer and consumer

func (*Kraft) ConsumeMessages

func (k *Kraft) ConsumeMessages(topic string, partition int32)

ConsumeMessages consumes messages from a Kafka topic

func (*Kraft) PushMessageToQueue

func (k *Kraft) PushMessageToQueue(topic string, message []byte) error

PushMessageToQueue sends a message to a Kafka topic

type Logger

type Logger struct {
	*slog.Logger
}

func (*Logger) Debug

func (l *Logger) Debug(message ...string)

func (*Logger) Error

func (l *Logger) Error(message ...string)

func (*Logger) Info

func (l *Logger) Info(message ...string)

func (*Logger) Warn

func (l *Logger) Warn(message ...string)

type Response

type Response struct {
	Status  bool           `json:"status"`
	Message string         `json:"message"`
	Data    map[string]any `json:"data"`
}

func (*Response) SetData

func (r *Response) SetData(key string, value any) *Response

func (*Response) SetMessage

func (r *Response) SetMessage(message string) *Response

func (*Response) SetStatus

func (r *Response) SetStatus(status bool) *Response

Jump to

Keyboard shortcuts

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