internal

package
v0.0.0-...-5a726a0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JWTKey = []byte(os.Getenv("JWT_SECRET_KEY"))

JWTKey is used to create the signature

Functions

func CORS

func CORS(next http.Handler) http.Handler

CORS middleware handles a gorilla middleware for implementing CORS functionality

func FromJSON

func FromJSON(i interface{}, r io.Reader) error

FromJSON deserializes the json structure to the given interface

func ToJSON

func ToJSON(i interface{}, w io.Writer) error

ToJSON serializes a interface to a valid json structure

Types

type Account

type Account struct {
	// the id for this account
	// required: true
	// min: 1
	ID uint `json:"id"`

	// the name of this account
	// required: true
	Name string `json:"name" validate:"required"`

	// the email of this account
	// required: true
	Email *string `json:"email" validate:"required"`

	// the password for this account
	// required: true
	Password string `json:"-" validate:"required"`

	// the username of this account
	// required: true
	Username string `json:"username" validate:"required"`

	// the age of this account
	Age uint8 `json:"age"`

	// the birthday of this account
	// required: true
	Birthday    *time.Time   `json:"birthday" validate:"required"`
	ActivatedAt sql.NullTime `json:"-"`
	CreatedAt   time.Time    `json:"-"`
	UpdatedAt   time.Time    `json:"-"`
}

Account is the database struct swagger:model

func (*Account) Validate

func (a *Account) Validate() error

Validate checks the validation of the user struct

type Claims

type Claims struct {
	Email string `json:"email"`
	jwt.StandardClaims
}

Claims is a struct that will be encoded in a jwt

type Database

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

Database for creating connection and handling transaction to the database

func NewDatabase

func NewDatabase(logger *log.Logger) *Database

NewDatabase returns a new database connection with the given logger

func (*Database) CreateConnection

func (d *Database) CreateConnection() (*sql.DB, *gorm.DB)

CreateConnection creates a connection to the postgres database It is not closing the connection to the database

type Validation

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

Validation contains following fields

func NewValidation

func NewValidation() *Validation

NewValidation creates a new validation type

func (*Validation) Validate

func (v *Validation) Validate(i interface{}) ValidationErrors

Validate the item

type ValidationError

type ValidationError struct {
	validator.FieldError
}

ValidationError wraps the validators FieldError

type ValidationErrors

type ValidationErrors []ValidationError

ValidationErrors is a collection of ValidationError

Jump to

Keyboard shortcuts

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