-
Notifications
You must be signed in to change notification settings - Fork 0
/
ungo.go
63 lines (57 loc) · 1.48 KB
/
ungo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ungo
import (
"errors"
"ungo/shorteners"
)
type Config struct {
Url string
Shortener string
}
type Decoded struct {
UrlDecoded string
UrlError error
}
type function func(string) (string, error)
func Shorten(info Config) (string, error) {
shortenersMap := map[string]function{
"1bebiz": ungo.Bebiz,
"1tinynet": ungo.Tinynet,
"adfly": ungo.Adfly,
"ad2links": ungo.Ad2links,
"ad7biz": ungo.Ad7biz,
"adfocus": ungo.Adfocus,
"amankanlink": ungo.Amankanlink,
"coegin": ungo.Coegin,
"comicon": ungo.Comicon,
"googl": ungo.Googl,
"gtaind": ungo.Gtaind,
"hrefli": ungo.Hrefli,
"imagebam": ungo.Imagebam,
"imagecurl": ungo.Imagecurl,
"imgfiles": ungo.ImgFiles,
"img3x": ungo.Img3x,
"imagep2p": ungo.Imagep2p,
"linkbucks": ungo.Linkbucks,
"linkshrink": ungo.Linkshrink,
"linktl": ungo.Linktl,
"motonewsclub":ungo.Motonewsclub,
"picnictrans": ungo.Picnictrans,
"playimg": ungo.Playimg,
"ppw": ungo.Ppw,
"shst": ungo.Shst,
"shtio": ungo.Shtio,
"shortenid": ungo.Shortenid,
"smllio": ungo.Smllio,
"tco": ungo.Tco,
"urlgogs": ungo.Urlgogs,
"voyeurimage": ungo.Voyeurimage,
}
if info.Shortener == "" {
return "", errors.New("Shortener can not be empty ...")
}
if urlReturn, ok := shortenersMap[info.Shortener]; ok {
return urlReturn(info.Url)
} else {
return "", errors.New("The Shortener state is not valid!")
}
}