Documentation ¶
Overview ¶
Package urlexpander provides a library to expand shortened urls from services like goo.gl, bitly.com, tinyurl.com
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDisallowedByRobotsTxt = errors.New("Provided URL is disallowed by robots.txt")
View Source
var ErrInvalidUrl = errors.New("Provided URL is not valid")
View Source
var ErrLongUrl = errors.New("Provided URL is not shortened")
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // User agent string used when translating shortened url. UserAgent string // Maximum length of shortened url. It is assumed that no shortened url is longer than that. ShortUrlMaxLength int // Expanded urls are cached for repeated use. Using this option cache capacity can be set. CacheCapacity int // Expanded urls are cached for repeated use. Using this option expiration timeout can be set. CacheExpiration time.Duration }
type UrlExpander ¶
type UrlExpander interface { // Expand given shortened url to its original form. // Return either an expanded url as a string or an error. ExpandUrl(shortenedUrl string) (string, error) }
func NewFromConfig ¶
func NewFromConfig(config Config) UrlExpander
Create a new UrlExpander with provided config
Click to show internal directories.
Click to hide internal directories.