server

package
v0.0.0-...-ccc207d Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetUniqueId = func() string {

	id, err := gonanoid.Generate(alphabet, 8)
	if err != nil {
		log.Fatal("Could not generate id")
	}
	return id
}
View Source
var PASSWORD string = os.Getenv("AUTH_PASSWORD")

Functions

func GenerateURL

func GenerateURL(input *pb.URLGenerateRequest, ID string) string

func GetUrlsForEmails

func GetUrlsForEmails(emails []string) []string

func UnwrapNullString

func UnwrapNullString(str sql.NullString) string

Types

type HitRecord

type HitRecord struct {
	Id        string
	Url       string
	Email     string
	Username  string
	HitDate   time.Time
	UrlType   string
	IPAddress string
	Note      string
}

type PixelRecord

type PixelRecord struct {
	Id           string
	Url          string
	Email        string
	Username     string
	Hits         int
	Created      time.Time
	LastModified time.Time
	Note         string
}

type Server

type Server struct {
	pb.UnimplementedTrackerServer
	DB *sql.DB
	Mu *sync.RWMutex
}

server is used to implement helloworld.GreeterServer.

func New

func New() *Server

New initializes a new Backend struct.

func (*Server) CheckIfIdExistsInDB

func (server *Server) CheckIfIdExistsInDB(id, table string) bool

func (*Server) CreateTableIfNotExists

func (server *Server) CreateTableIfNotExists()

func (*Server) GenerateID

func (server *Server) GenerateID(input *pb.URLGenerateRequest) string

func (*Server) GetTablePixels

func (server *Server) GetTablePixels() *[]PixelRecord

func (*Server) GetTableUrlHitsFromDB

func (server *Server) GetTableUrlHitsFromDB() *[]HitRecord

func (*Server) GetTableUrlsFromDB

func (server *Server) GetTableUrlsFromDB() *[]UrlRecord

func (*Server) GetUrl

func (server *Server) GetUrl(ctx context.Context, input *pb.URLGenerateRequest) (*pb.Url, error)

func (*Server) GetUrlCallback

func (server *Server) GetUrlCallback(input *pb.URLGenerateRequest) (*pb.Url, error)

func (*Server) GetUrlForIDFromDB

func (server *Server) GetUrlForIDFromDB(requestId string) UrlRecord

func (*Server) IncrementHitDB

func (server *Server) IncrementHitDB(id, table string)

func (*Server) SaveUrlHitToDB

func (server *Server) SaveUrlHitToDB(url UrlRecord, id, ipAddr string)

func (*Server) SaveUrlToDB

func (server *Server) SaveUrlToDB(url string, id string, input *pb.URLGenerateRequest)

func (*Server) StartHTTPServer

func (server *Server) StartHTTPServer()

type URLType

type URLType int

type UrlRecord

type UrlRecord struct {
	Id           string
	Url          string
	Email        string
	Username     string
	Hits         int
	Created      time.Time
	LastModified time.Time
	UrlType      string
	Note         string
}

Jump to

Keyboard shortcuts

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