gxurl

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

2017-10-31 14:30 Package gxurl implements URL function encapsulation

Index

Constants

View Source
const (
	GitioShortURL = "https://git.io"
	BaiduShortURL = "http://dwz.cn/create.php"
	// SinaShortURL  = "http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long="
	SinaShortURL  = "http://api.t.sina.com.cn/short_url/shorten.json?source=1681459862&url_long="
	GoogdShortURL = "http://www.goo.gd/action/json.php?source=1681459862&url_long="
	So985ShortURL = "http://api.c7.gg/api.php?format=json&url="
)

Variables

View Source
var (
	ErrorHTTPPrefix = fmt.Errorf("The url should start with http:// or https://")
)

Functions

func GenBaiduShortURL

func GenBaiduShortURL(uri string) (string, error)

GenBaiduShortURL generates short url by dwz.com

func GenGitioShortURL

func GenGitioShortURL(uri string) (string, error)

GenGitioShortURL generates short url by git.io.

func GenSinaShortURL

func GenSinaShortURL(uri string) (string, error)

GenSinaShortURL generates short url by sina.com ref doc: http://open.weibo.com/wiki/Short_url/shorten

func GenSinaShortURLByGoogd

func GenSinaShortURLByGoogd(uri string) (string, error)

GenSinaShortURL generates short url by sina.com

func GenSo985ShortURL added in v0.3.0

func GenSo985ShortURL(uri string) (string, error)

GenSo985ShortURL generates short url by git.io.

Types

type BaiduResult

type BaiduResult struct {
	UrlShort string `json:"tinyurl"`
	UrlLong  string `json:"longurl"`
	Status   int    `json:"status"`
	ErrMsg   string `json:"err_msg"`
}

type GoogdResult

type GoogdResult struct {
	Result     bool   `json:"result"`
	UrlShort   string `json:"url_short"`
	UrlLong    string `json:"url_long"`
	ObjectType string `json:"object_type"`
	Type       int    `json:"type"`
	ObjectID   string `json:"object_id"`
}

type GoogdResults

type GoogdResults struct {
	Urls []GoogdResult `json:"urls"`
}

type SinaResult

type SinaResult struct {
	UrlShort string `json:"url_short"`
}

type So985Result added in v0.3.0

type So985Result struct {
	UrlShort string `json:"url"`
	Err      string `json:"err"`
}

Jump to

Keyboard shortcuts

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