yasuser

command module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

Yasuser

Yet another self-hosted URL shortener.

Short or Restore your URL, like https://git.io/ or https://goo.gl/ but under YOUR control.

Master Build Status Go Report Card license Docker Pulls

Run

docker run --name yasuser -dti \
    -p 8084:8084 \
    -e YASUSER_SHORTENER_STORE_DBPATH=/data/yasuser.db \
    -e YASUSER_SERVER_DOMAIN=http://localhost:8084 \
    -v `pwd`:/data \
    wrfly/yasuser

Or use the docker-compose.yml.

Configuration example (./yasuser -e):

debug: false
store:
  dbpath: ./yasuser.db
  dbtype: bolt  # bolt or redis
  redis: redis://localhost:6379
server:
  domain: https://u.kfd.me
  port: 8084    # port to listen
  limit: 10     # go tool pprof http://localhost:8084/debug/pprof/heap
  pprof: false  # go tool pprof http://localhost:8084/debug/pprof/heap
  gaid: 62244864-8  # google analytics ID
filter:
  domain:
    whitelist: []
    blacklist: []
  keyword:
    whitelist: []
    blacklist: []

All the configuration can be set via environment:

YASUSER_DEBUG=false
YASUSER_STORE_DBPATH=./yasuser.db
YASUSER_STORE_DBTYPE=bolt
YASUSER_STORE_REDIS=redis://localhost:6379
YASUSER_SERVER_DOMAIN=https://u.kfd.me
YASUSER_SERVER_PORT=8084
YASUSER_SERVER_LIMIT=10
YASUSER_SERVER_PPROF=false
YASUSER_SERVER_GAID=62244864-8
YASUSER_FILTER_DOMAIN_WHITELIST=
YASUSER_FILTER_DOMAIN_BLACKLIST=
YASUSER_FILTER_KEYWORD_WHITELIST=
YASUSER_FILTER_KEYWORD_BLACKLIST=

Usage

# short your URL
➜  ~ curl https://u.kfd.me -d "https://kfd.me"
https://u.kfd.me/1C
➜  ~

# restore it
➜  ~ curl https://u.kfd.me/1C
<a href="https://kfd.me">Found</a>.

# customize the short URL
➜  ~ curl https://u.kfd.me/ -d "https://kfd.me/hello" -H "custom: kfd"  
https://u.kfd.me/kfd

# conflict
➜  ~ curl https://u.kfd.me/ -d "https://kfd.me/world" -H "custom: kfd"
custom URL already exist

# restore the customized URL
➜  ~ curl https://u.kfd.me/kfd
<a href="https://kfd.me/hello">Found</a>.

# set TTL for a URL; bolt db will tell you the URL is expired while
# the redis will just delete it
➜  ~ curl https://u.kfd.me/ -d "https://kfd.me/kfd" -H "ttl: 1s"
https://u.kfd.me/1B
➜  ~ sleep 1 && curl https://u.kfd.me/1B
url expired

# set TTL for a customized URL
➜  ~ curl https://u.kfd.me/ -d "https://kfd.me/kfd" -H "ttl: 1s" -H "custom: 666"
https://u.kfd.me/666
➜  ~ sleep 1 && curl https://u.kfd.me/666
url expired

Or just visit the web page:

index

Benckmark

See benchmark

Features

  • it works
  • blob database
  • length and validate
  • memory cache
  • redis database
  • customization
  • TTL of URL
  • rate limit
  • [ ] management(auth)
    • domain filter
    • keyword filter
  • statistic
    • URL status
    • runtime metrics
    • status badge
  • UI index
    • google analytics
    • prettify the index
  • pprof

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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