utils

package
v0.0.0-...-b623679 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Global instance of the validator

Functions

func CompareHashedAndPlain

func CompareHashedAndPlain(hashed, plain string) bool

Compares hashed strings with plaintext ones

func ContextClaimExpiration

func ContextClaimExpiration(r *http.Request) (time.Time, error)

Claims the jwt expiration from the request

func ContextClaimID

func ContextClaimID(r *http.Request) (int, error)

Claims the account's id from the request

func GenerateRandomCode

func GenerateRandomCode(lenght int) (string, error)

Generating a random alphanumeric code

func Hash

func Hash(password string) (string, error)

Hashes a string

func Request

func Request(method string, headers map[string]string, endpoint string, payload any) (*http.Response, error)

Sends a request

func Response

func Response(w http.ResponseWriter, status int, v any) error

Sends a response

func Unmarshal

func Unmarshal(w http.ResponseWriter, r *http.Request, payload any) error

Unmarshals json into a type struct

func Validate

func Validate(w http.ResponseWriter, r *http.Request, payload any) error

Validates a struct

Types

This section is empty.

Jump to

Keyboard shortcuts

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