internal

package
v0.0.0-...-11bce7f Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Port           = ":8080"
	TokenIssuer    = "https://.com"
	Issuer2        = "accounts.google.com"
	CAccessToken   = "access-token"
	CAccessClaims  = "access-claims"
	CRefreshToken  = "refresh-token"
	CRefreshClaims = "refresh-claims"
)

Variables

View Source
var (
	Env = os.Getenv("ENV")

	TokenSignatureKey string = "secret overwritten by init.go"
	ClientKey         string = os.Getenv("ANDROID_KEY")
	SwaggerUrl        string = "https://www.google.com/"

	//Database
	DB     *sql.DB = nil
	DB_URL string  = os.Getenv("DB_URL")
)

ENV and SECRETS

Functions

func ValidateToken

func ValidateToken(c *gin.Context, tokenString string) (*jwt.Token, *Claims, *Error)

Types

type Claims

type Claims struct {
	ID          int    `json:"id"`
	UserName    string `json:"user_name"`
	DisplayName string `json:"display_name"`
	Email       string `json:"email"`
	jwt.StandardClaims
}

Define a struct that will be encoded to a token

func GetAccessTokenFromCtx

func GetAccessTokenFromCtx(c *gin.Context) (*jwt.Token, *Claims)

func GetRefreshTokenFromCtx

func GetRefreshTokenFromCtx(c *gin.Context) (*jwt.Token, *Claims)

type Credentials

type Credentials struct {
	Id          int    `json:"id"`
	UserName    string `json:"user_name" binding:"required"`
	DisplayName string `json:"display_name"`
	Email       string `json:"email" binding:"required"`
	Password    string `json:"password"`
}

Credentials represents the data needed to generate a token.

type Error

type Error struct {
	Time   string `json:"time_RFC3339"`
	Path   string `json:"path"`
	Status int    `json:"status"`
	Error  string `json:"error"`
}

Error represents the data returned by an aborted HTTP request.

func DetailError

func DetailError(status int, err error) *Error

DetailError returns an Error struct with the given status and message.

func IntIdtoUint

func IntIdtoUint(num int) (uint, *Error)

type HandlerResponse

type HandlerResponse struct {
	Code int         `json:"code"`
	Data interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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