url

package
v0.0.0-...-06b6469 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValidation = errors.New("validation error")

ErrValidation is a generic validation error that can be returned when input validation fails

Functions

This section is empty.

Types

type GetUrlByTokenInput

type GetUrlByTokenInput struct {
	Token string
	// contains filtered or unexported fields
}

GetUrlInput is the input struct for the GetUrl method

type GetUrlByUrlInput

type GetUrlByUrlInput struct {
	Url string
	// contains filtered or unexported fields
}

GetUrlInput is the input struct for the GetUrl method

type SaveUrlInput

type SaveUrlInput struct {
	Url string
	// contains filtered or unexported fields
}

SaveUrlInput is the input struct for the SaveUrl method

type Service

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

func NewService

func NewService(repo UrlEntryRepository) *Service

New will create a new service

func (*Service) GetUrlByToken

func (s *Service) GetUrlByToken(ctx context.Context, input *GetUrlByTokenInput) (*entity.UrlEntry, error)

GetUrl will get the url entry from the url string

func (*Service) GetUrlByUrl

func (s *Service) GetUrlByUrl(ctx context.Context, input *GetUrlByUrlInput) (*entity.UrlEntry, error)

GetUrl will get the url entry from the url string

func (*Service) SaveUrl

func (s *Service) SaveUrl(ctx context.Context, input *SaveUrlInput) (*entity.UrlEntry, error)

SaveUrl will validate the url string and save it to the store

func (*Service) VisitUrlByToken

func (s *Service) VisitUrlByToken(ctx context.Context, input *VisitUrlByTokenInput) error

VisitUrl will increment the number of times the url has been visited

type UrlEntryRepository

type UrlEntryRepository interface {
	// Save will url entry to the store
	SaveUrl(ctx context.Context, url entity.Url) (entry *entity.UrlEntry, err error)
	// SaveVisit will increment the number of times the url has been visited
	SaveVisit(ctx context.Context, token entity.UrlToken) error
	// GetFromToken will get the url entry from the token
	GetFromToken(ctx context.Context, token entity.UrlToken) (*entity.UrlEntry, error)
	// GetFromUrl will get the url entry from the url
	GetFromUrl(ctx context.Context, url entity.Url) (*entity.UrlEntry, error)
}

UrlEntryRepository is the interface that defines the method that the service will use to interact with the repository

type VisitUrlByTokenInput

type VisitUrlByTokenInput struct {
	Token string
	// contains filtered or unexported fields
}

VisitUrlInput is the input struct for the VisitUrl method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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