tinyurl

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 4 Imported by: 0

README

tinyUrl

tinyUrl 是一个使用 Go 语言与 Base36 编码实现的短链接服务,并且支持 URL 替换功能,即可以将https://www.amazon.com/%E6%9C%9D%E8%8A%B1%E5%A4%95%E6%8B%BE-%E9%B2%81%E8%BF%85/dp/7519015432这样的长链接转换为类似于http://localhost/t/6c7f的短链接。

当短链接映射的网址发生改变,例如域名或协议发生变化时,我们可以更新短链接映射的网址,从而实现短链接的长期有效。

tinyUrl 默认数据一写入就落盘存储,相关内容在 storage 模块中实现。

这还是一个早期版本,目前已在本人的博客中搭建并提供基础功能。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTinyUrlTooSmall = errors.New("the tinyUrl is too small")
	ErrTinyUrlNotExist = errors.New("the tinyUrl is not exist")
)

Functions

func Create added in v0.1.2

func Create(url []byte) (string, error)

Create() will create a tinyUrl

func Delete added in v0.1.2

func Delete(tinyUrl string) error

Update() will delete a tinyUrl from storage, and it will not be found

func Get added in v0.1.2

func Get(tinyUrl string) ([]byte, error)

Get() will get a url by tinyUrl

func New

func New()

New() will init a Storage interface

func Update added in v0.1.2

func Update(tinyUrl, newUrl string) error

Update() will update a tinyUrl, and the tinyUrl will direct to a new url

Types

This section is empty.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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