model

package
v0.0.0-...-28ab817 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_PENDING = "pending"
	STATUS_ERROR   = "error"
	STATUS_ISSUED  = "issued"
)

Variables

This section is empty.

Functions

func Hash

func Hash(password string) ([]byte, error)

Hash is a method that returns a hashed version of a plain text password

Types

type APIEnvelopeResponse

type APIEnvelopeResponse struct {
	Status  int         `json:"status" example:"201"`
	Message string      `json:"message" example:"use this JWT token as a bearer token to authenticate into the API"`
	Data    interface{} `json:"data"`
}

APIEnvelopeResponse is a generic API Response used only for openapi generation

type Pagination

type Pagination struct {
	Limit int    `json:"limit"`
	Page  int    `json:"page"`
	Sort  string `json:"sort"`
}

Pagination is a struct used to store pagination data for GetAll API requests

func GeneratePaginationFromRequest

func GeneratePaginationFromRequest(c *gin.Context) Pagination

GeneratePaginationFromRequest is a method used to turn extract data from a http request into a Pagination struct

type Request

type Request struct {
	Id            int            `json:"id" gorm:"primary_key;auto_increment;not null" example:"1"`
	Domain        string         `json:"domain" binding:"required" gorm:"not null" example:"mydomain.com"`
	ChallengeType string         `json:"challengeType" binding:"required" gorm:"not null" example:"challenge-http"`
	Status        string         `json:"status" gorm:"not_null" example:"pending"`
	IssuedAt      *time.Time     `json:"issuedAt" gorm:"default:null" example:"2022-07-06 12:03:10.0"`
	CreatedAt     time.Time      `json:"createdAt" example:"2022-06-06 12:03:10.0"`
	UpdatedAt     time.Time      `json:"updatedAt" example:"2022-06-06 12:03:10.0"`
	DeletedAt     gorm.DeletedAt `json:"deletedAt" swaggertype:"primitive,string" gorm:"index" example:"2022-06-06 12:03:10.0"`
}

Request is a database struct that is used to store certificate requests in the database

func (*Request) GetAll

func (h *Request) GetAll() ([]Request, error)

GetAll is a method used for getting all certificate requests from the database in a paginated array

func (*Request) GetAllExpiringSoon

func (h *Request) GetAllExpiringSoon() ([]Request, error)

GetAllExpiringSoon is a method used for getting all certificate requests from the database that are 1 month from expiration

func (*Request) GetByID

func (h *Request) GetByID(id string) error

GetByID is a method used to get one certificate request by its ID

func (*Request) Save

func (h *Request) Save() error

Save is a method used to save a NEW certificate request to the database. If you need to update one instead, use the Update method.

func (*Request) Update

func (h *Request) Update() error

Update is a method used to save changes to an existing record to the database.

type RequestCreate

type RequestCreate struct {
	Domain        string `json:"domain" binding:"required" example:"mydomain.com"`
	ChallengeType string `json:"challengeType" binding:"required" enums:"challenge-tls,challenge-http,challenge-dns"`
}

RequestCreate is a struct used only for openapi documentation generation to show the input data for creating a certificate request

type User

type User struct {
	Id        int            `json:"id" gorm:"primary_key;auto_increment;not null" swaggerignore:"true"`
	Email     string         `json:"email" binding:"required" gorm:"size:100;not null;unique" example:"example@chargeover.com"`
	Password  string         `json:"password" binding:"required" gorm:"size:100;not null" example:"correct-horse-battery-staple"`
	CreatedAt time.Time      `swaggerignore:"true"`
	UpdatedAt time.Time      `swaggerignore:"true"`
	DeletedAt gorm.DeletedAt `swaggerignore:"true"`
}

User is a database struct used to store a record

func (*User) Authenticate

func (u *User) Authenticate() bool

Authenticate is a method used to verify a users credentials

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) error

BeforeSave is an ORM lifecycle hook to hash a users password before insertion

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) error

VerifyPassword is a method compares a plaintext password against a hashed version to see if they match

type UserResponse

type UserResponse struct {
	Status  int    `json:"status" binding:"required" example:"201"`
	Message string `json:"message" binding:"required" example:"use this JWT token as a bearer token to authenticate into the API"`
	Data    string `json:"data" binding:"required" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6I... (truncated)"`
}

UserResponse is a struct used for openapi docs generation to a api response sample from the API

Jump to

Keyboard shortcuts

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