Skip to content

casperkwok/shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

短链接服务

用 Go 写的短链接工具,把长网址变短。

怎么用

go mod tidy
go run main.go

服务跑在 8088 端口。

接口

生成短链接:

curl -X POST http://localhost:8088/shorten \
     -H "Content-Type: application/json" \
     -d '{"url":"https://www.baidu.com"}'

返回:{"short_url":"/abc123"}

访问短链接:
浏览器打开 http://localhost:8088/abc123 就会跳转到原网址。

配置

config.yaml:

server_port: ":8088"
db_path: "shortener.db"

技术

Go + Gin + SQLite

About

Go 短链接服务 - 简单的 URL 缩短工具

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages