handlers

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "http://localhost:8000"

TODO switch to cfg baseURL

Variables

This section is empty.

Functions

func BuildSubscriber

func BuildSubscriber(row pgx.CollectableRow) (subscriber *models.Subscriber, err error)

func GenerateCSPRNG

func GenerateCSPRNG(tokenLen int) (csprng string, err error)
func GenerateConfirmationLink(c context.Context, tx pgx.Tx, subscriberEmail *models.SubscriberEmail) (confirmation string, err error)

func HandleError

func HandleError(c *gin.Context, id string, e error, response string, status int)

func HealthCheck

func HealthCheck(c *gin.Context)

func StoreToken

func StoreToken(c context.Context, tx pgx.Tx, id string, token string) (err error)

Types

type DatabaseHandler

type DatabaseHandler struct {
	DB      DatabaseInterface
	Context *context.Context
}

func NewDatabaseHandler

func NewDatabaseHandler(database DatabaseInterface) *DatabaseHandler

type DatabaseInterface

type DatabaseInterface interface {
	Exec(c context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(c context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(c context.Context, sql string, args ...interface{}) pgx.Row
	Begin(c context.Context) (pgx.Tx, error)
}

type Loader

type Loader struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

Jump to

Keyboard shortcuts

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