Documentation ¶
Index ¶
- Constants
- func ComparePassword(password string, hash string) (bool, error)
- func FormatAPIResponse(context *gin.Context, code int, data any)
- func GetStatusMessage(code int) string
- func HashPassword(password string) (string, error)
- func IsEmail(str string) bool
- func SignJWTToken(user models.User) (string, error)
- type Claims
- type HashOptions
- type Response
- type Status
Constants ¶
View Source
const ( StatusContinue = 100 StatusSwitchingProtocols = 101 StatusProcessing = 102 StatusEarlyHints = 103 StatusOK = 200 StatusCreated = 201 StatusAccepted = 202 StatusNonAuthoritativeInfo = 203 StatusNoContent = 204 StatusResetContent = 205 StatusPartialContent = 206 StatusMultiStatus = 207 StatusAlreadyReported = 208 StatusIMUsed = 226 StatusMultipleChoices = 300 StatusMovedPermanently = 301 StatusFound = 302 StatusSeeOther = 303 StatusNotModified = 304 StatusUseProxy = 305 StatusTemporaryRedirect = 307 StatusPermanentRedirect = 308 StatusBadRequest = 400 StatusPaymentRequired = 402 StatusForbidden = 403 StatusNotFound = 404 StatusMethodNotAllowed = 405 StatusNotAcceptable = 406 StatusProxyAuthRequired = 407 StatusRequestTimeout = 408 StatusConflict = 409 StatusGone = 410 StatusLengthRequired = 411 StatusPreconditionFailed = 412 StatusPayloadTooLarge = 413 StatusURITooLong = 414 StatusUnsupportedMediaType = 415 StatusRangeNotSatisfiable = 416 StatusExpectationFailed = 417 StatusTeapot = 418 StatusMisdirectedRequest = 421 StatusUnprocessableEntity = 422 StatusLocked = 423 StatusFailedDependency = 424 StatusUpgradeRequired = 426 StatusPreconditionRequired = 428 StatusTooManyRequests = 429 StatusRequestHeaderFieldsTooLarge = 431 StatusInternalServerError = 500 StatusNotImplemented = 501 StatusBadGateway = 502 StatusGatewayTimeout = 504 StatusHTTPVersionNotSupported = 505 StatusVariantAlsoNegotiates = 506 StatusInsufficientStorage = 507 StatusLoopDetected = 508 StatusNotExtended = 510 StatusNetworkAuthenticationRequired = 511 )
Define an enum of status codes using constants
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword compares a password with a hash
func FormatAPIResponse ¶
APIResponse handles the response formatting and error checking
func GetStatusMessage ¶
Function to get message by status code
func HashPassword ¶
HashPassword generates a hashed password
Types ¶
type Claims ¶
type Claims struct { ID primitive.ObjectID `bson:"_id,omitempty"` Username string `json:"username"` jwt.RegisteredClaims }
func ValidateJWTToken ¶
ValidateJWTToken parses and validates a JWT token
type HashOptions ¶
type HashOptions struct { Rounds int // number of bcrypt rounds Password string // password to hash or compare Hash string // hash to compare with }
HashOptions represents options for hashing and comparison
Click to show internal directories.
Click to hide internal directories.