An elegant URL Shortener service
hyphen -l 0.0.0.0:9010 --data ./data/bbolt_data.db
docker run -it --rm -p 9010:9010 -v <path/to/bbolt/db/data>:/var/lib/hyphen nekomeowww/hyphen:latest
docker-compose up -d
Remember to specify your version with -ldflags " -X 'github.com/nekomeowww/hyphen/pkg/meta.Version=<version to be specified>'"
go build -a -o "release/hyphen" -ldflags " -X 'github.com/nekomeowww/hyphen/pkg/meta.Version=<version>'" "github.com/nekomeowww/hyphen/cmd/hyphen"
Remember to specify your version with --build-arg VERSION=<version to be specified>
docker buildx build --platform <your/arch> -t <tag> --build-arg VERSION=<version> . -f Dockerfile
Query one short URL by original URL.
Query Params:
url
String
(required): original URL
Response:
{
"data": {
"shortUrl": "2f224d525e"
}
}
Query one original URL by short URL.
Query Params:
url
String
(required): Short URLredirect
Boolean
: Whether to redirect to the original URL automatically (by returning301 Permanently Moved
)
Response:
{
"data": {
"url": "https://example.com/8b4e9413fd13f4a83a2a31c8494347"
}
}
Create a new URL. The short URL will be created based on the first 10 letter of sha512 hash of the original URL.
Body Params:
{
"url": "https://example.com/8b4e9413fd13f4a83a2a31c8494347"
}
Response:
{
"data": {
"url": "https://example.com/8b4e9413fd13f4a83a2a31c8494347",
"shortUrl": "2f224d525e",
}
}
Revoke the short URL that created in the past.
NOTICE: since hyphen
is creating short URL base on the sha512 hash of the original URL,
revoke will disconnect all the original URL to the short URL that revoked, however, you could
create a new one to reconnect them together, it will return the same short URL as before.
Body Params:
{
"shortUrl": "2f224d525e"
}
Response:
{
"data": {
"ok": true
}
}