Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlwaysTrue ¶
AlwaysTrue always returns true. Used for GenerateID and GenerateShortID.
Types ¶
type RedisKey ¶
type RedisKey uint64
RedisKey is used to be able to specify keys at RedisKeyf (as magic constant)
type ShortID ¶
type ShortID string
ShortID -> ID of a ShortURL object of type string
func GenerateID ¶
GenerateID generates a string of length {length} using the characters from availableCharacters. This generated string is checked against the {accept} function and, if this function returns true, it will return the generated string. Otherwise, the process is tried a total of 5 more times until the {accept} function returns true, or the attempts are exhausted. After that an empty string is returned.
func GenerateShortID ¶
GenerateShortID generates a 5 - 10 long string and checks it against the {accept} function. More information: GenerateID()
func (*ShortID) BsonFilter ¶
BsonFilter returns a bson map (bson.M) with the search option: "id": ShortID
type ShortURL ¶
type ShortURL struct { ID ShortID `json:"id" bson:"id"` FullURL string `json:"full_url" bson:"full_url"` CreationDate time.Time `json:"creation_date" bson:"creation_date"` ExpirationDate *time.Time `json:"expiration_date" bson:"expiration_date"` Secret string `json:"secret" bson:"secret"` }
ShortURL -> Structure for shortened urls
func (*ShortURL) BsonUpdate ¶
BsonUpdate returns a bson map (bson.M) with the field "$set": ShortURL