Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator interface {
CreateShortLink(shortLinkInput entity.ShortLinkInput, user entity.User, isPublic bool) (entity.ShortLink, error)
}
Creator represents a ShortLink alias creator
type CreatorPersist ¶
type CreatorPersist struct {
// contains filtered or unexported fields
}
CreatorPersist represents a ShortLink alias creator which persist the generated alias in the repository
func NewCreatorPersist ¶
func NewCreatorPersist( shortLinkRepo repository.ShortLink, userShortLinkRepo repository.UserShortLink, keyGen keygen.KeyGenerator, longLinkValidator validator.LongLink, aliasValidator validator.CustomAlias, timer timer.Timer, riskDetector risk.Detector, ) CreatorPersist
NewCreatorPersist creates CreatorPersist
func (CreatorPersist) CreateShortLink ¶
func (c CreatorPersist) CreateShortLink(shortLinkInput entity.ShortLinkInput, user entity.User, isPublic bool) (entity.ShortLink, error)
CreateShortLink persists a new short link with a given or auto generated alias in the repository. TODO(issue#235): add functionality for public URLs
type ErrAliasExist ¶
type ErrAliasExist string
ErrAliasExist represents alias unavailable error
func (ErrAliasExist) Error ¶
func (e ErrAliasExist) Error() string
type ErrEmptyAlias ¶
type ErrEmptyAlias string
ErrEmptyAlias represents empty alias provided.
func (ErrEmptyAlias) Error ¶
func (e ErrEmptyAlias) Error() string
type ErrInvalidCustomAlias ¶
type ErrInvalidCustomAlias struct { Violation validator.Violation // contains filtered or unexported fields }
ErrInvalidCustomAlias represents incorrect custom alias format error
func (ErrInvalidCustomAlias) Error ¶
func (e ErrInvalidCustomAlias) Error() string
type ErrInvalidLongLink ¶
ErrInvalidLongLink represents incorrect long link format error
func (ErrInvalidLongLink) Error ¶
func (e ErrInvalidLongLink) Error() string
type ErrMaliciousLongLink ¶
type ErrMaliciousLongLink string
ErrMaliciousLongLink represents malicious long link error
func (ErrMaliciousLongLink) Error ¶
func (e ErrMaliciousLongLink) Error() string
type ErrShortLinkNotFound ¶
type ErrShortLinkNotFound string
ErrShortLinkNotFound represents the failure of finding certain short link in the data store
func (ErrShortLinkNotFound) Error ¶
func (e ErrShortLinkNotFound) Error() string
type MetaTag ¶
type MetaTag interface { GetOpenGraphTags(alias string) (metatag.OpenGraph, error) GetTwitterTags(alias string) (metatag.Twitter, error) }
MetaTag fetches and updates MetaTags for a short link.
type MetaTagPersist ¶
type MetaTagPersist struct {
// contains filtered or unexported fields
}
MetaTagPersist fetches and updates MetaTags for a short link from persistent storage.
func NewMetaTagPersist ¶
func NewMetaTagPersist(shortLinkRepo repository.ShortLink) MetaTagPersist
NewMetaTagPersist creates NewMetaTagPersist given repository.
func (MetaTagPersist) GetOpenGraphTags ¶
func (m MetaTagPersist) GetOpenGraphTags(alias string) (metatag.OpenGraph, error)
GetOpenGraphTags retrieves Open Graph tags for a short link from persistent storage given alias.
func (MetaTagPersist) GetTwitterTags ¶
func (m MetaTagPersist) GetTwitterTags(alias string) (metatag.Twitter, error)
GetTwitterTags retrieves Twitter tags for a short link from persistent storage given alias.
type Retriever ¶
type Retriever interface { GetShortLink(alias string, expiringAt *time.Time) (entity.ShortLink, error) GetShortLinksByUser(user entity.User) ([]entity.ShortLink, error) }
Retriever represents ShortLink retriever
type RetrieverPersist ¶
type RetrieverPersist struct {
// contains filtered or unexported fields
}
RetrieverPersist represents ShortLink retriever that fetches ShortLink from persistent storage, such as database
func NewRetrieverPersist ¶
func NewRetrieverPersist(shortLinkRepo repository.ShortLink, userShortLinkRepo repository.UserShortLink) RetrieverPersist
NewRetrieverPersist creates persistent ShortLink retriever
func (RetrieverPersist) GetShortLink ¶
func (r RetrieverPersist) GetShortLink(alias string, expiringAt *time.Time) (entity.ShortLink, error)
GetShortLink retrieves ShortLink from persistent storage given alias
func (RetrieverPersist) GetShortLinksByUser ¶
GetShortLinksByUser retrieves ShortLinks created by given user from persistent storage
type Updater ¶
type Updater interface {
UpdateShortLink(oldAlias string, shortLinkInput entity.ShortLinkInput, user entity.User) (entity.ShortLink, error)
}
Updater mutates existing short links.
type UpdaterPersist ¶
type UpdaterPersist struct {
// contains filtered or unexported fields
}
UpdaterPersist persists the mutated short link in the data store.
func NewUpdaterPersist ¶
func NewUpdaterPersist( shortLinkRepo repository.ShortLink, userShortLinkRepo repository.UserShortLink, longLinkValidator validator.LongLink, aliasValidator validator.CustomAlias, timer timer.Timer, riskDetector risk.Detector, ) UpdaterPersist
NewUpdaterPersist creates a new UpdaterPersist instance.
func (UpdaterPersist) UpdateShortLink ¶
func (u UpdaterPersist) UpdateShortLink( oldAlias string, shortLinkInput entity.ShortLinkInput, user entity.User, ) (entity.ShortLink, error)
UpdateShortLink mutates a short link in the repository.