config

package
v0.0.0-...-f8464e9 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 23 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 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 LoadSQLQueries

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

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

func Logger

func Logger(fileName string, logger *log.Logger)

func RandomString

func RandomString(length int) string

func ReadJSON

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

func RenderView

func RenderView(view templ.Component, w http.ResponseWriter) error

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

type Response

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

func (*Response) SetData

func (r *Response) SetData(data 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