shorturls

package
v0.0.0-...-b23ed02 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ShortURLMeta

type ShortURLMeta struct {
	LongURL         string
	Tags            []string
	ValidSince      string
	ValidUntil      string
	CustomSlug      string
	MaxVisits       uint
	FindIfExists    bool
	Domain          string
	ShortCodeLength uint
}

ShortURLMeta represents metadata passed from REST or CLI to generate a short url

type ShortURLParams

type ShortURLParams struct {
	Domain    string
	ShortCode string
}

ShortURLParams is a struct with Domain and ShortCode to be used with ParseShortURL

type ShortURLService

type ShortURLService struct {
	Config *config.ConfigurationRepo
	DB     *gorm.DB
}

ShortURLService is the Service Logic for creating, updating, retrieving and deleting shortURLs

func NewService

func NewService(config *config.ConfigurationRepo, db *gorm.DB) *ShortURLService

NewService returns a new ShortURLs Service

func (*ShortURLService) AssignTags

func (s *ShortURLService) AssignTags(shortURL *models.ShortURL, tagNames []string) error

AssignTags Creates the Tags that don't exist and assigns them to the ShortURL

func (*ShortURLService) CreateShortURL

func (s *ShortURLService) CreateShortURL(meta *ShortURLMeta) (*models.ShortURL, error)

CreateShortURL generates a new short url based on meta received

func (*ShortURLService) DeleteShortURL

func (s *ShortURLService) DeleteShortURL(domain string, shortcode string) error

DeleteShortURL removes the ShortURL Model from the db even if it isn't valid

func (*ShortURLService) GetShortURL

func (s *ShortURLService) GetShortURL(domain string, shortcode string) (models.ShortURL, error)

GetShortURL retrieves the ShortURL Model from the db even if it isn't valid

func (*ShortURLService) GetShortURLs

func (s *ShortURLService) GetShortURLs(params URLSearchParams) (*[]models.ShortURL, error)

GetShortURLs retrieves a list of shortURLs

func (*ShortURLService) GetValidShortURL

func (s *ShortURLService) GetValidShortURL(domain string, shortcode string) (models.ShortURL, error)

GetValidShortURL retrieves the ShortURL Model from the db even if it isn't valid

func (*ShortURLService) ParseShortURL

func (s *ShortURLService) ParseShortURL(shortURL string) (ShortURLParams, error)

ParseShortURL returns the domain and shortcode of a given URL

func (*ShortURLService) SetDomain

func (s *ShortURLService) SetDomain(shortURL *models.ShortURL, domainAuthority string) error

SetDomain sets DomainId in ShortURL, creating that ID if necessary

type URLSearchParams

type URLSearchParams struct {
	Page       int      // The page to be displayed. Defaults to 1
	SearchTerm string   // A query used to filter results by searching for it on the longUrl and shortCode fields.
	Tags       []string // A list of tags used to filter the resultset. Only short URLs tagged with at least one of the provided tags will be returned.
	OrderBy    string   // The field from which you want to order the result. (Since v1.3.0) Available values : longUrl, shortCode, dateCreated, visits
	StartDate  string   // The date (in ISO-8601 format) from which we want to get short URLs
	EndDate    string   // The date (in ISO-8601 format) until which we want to get short URLs
}

URLSearchParams is a struct for passing params to search for a shortURL

Jump to

Keyboard shortcuts

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