Urlshorter is a RESTful web service used to help organizations to achieve short URLs.
303
1.0.1, latest
1.0(does not support redis re-connect)
Because of urlshorter use redis as its persist store, so a redis server should be available before run urlshorter.
NOTE:
urlshorteris a fail-fast image, so the startup order ofredisandurlshorteris not important,urlshortercan detectredisautomatically.
docker run -d -p 8080:8080 mengluo668/urlshorter:1.0
version: "3.7"
services:
redis:
image: redis:5.0.0
urlshorter:
image: mengluo668/urlshorter:1.0
environment:
- SU_ERROR_URL=http://www.baidu.com
ports:
- 8080:8080
// Request
POST /api/v1/generation HTTP/1.1
Host: urlshorter.example.com
Content-Type: application/json
Body:
{
"shortBaseUrl": "http://www.example.com",
"originalUrl":"http://test.example.com?hello=world&author=wenbo&license=ISC"
}
// Response
Content-Type: application/json
Body: http://www.example.com/fzjxXVMnV
// Request
GET /api/v1/code/fzjxXVMnV HTTP/1.1
Host: urlshorter.example.com
// Response (redirect to the orignal URL with 3xx status code)
301 http://test.example.com?hello=world&author=wenbo&license=ISC
The urlshorter allows you customize its behaviors based on environment. Available envs are:
8080SU:CODE:SU:ORI:redis6379'{}'. the value of this environment must be a string and can cast to json object.undefinedA1: If the ERROR_URI environment is set, the urlshorter will redirect to the ERROR_URI, otherwise return a error in JSON(content-type: application-json)
A2: Only 1 short url will be generate, and the urlshorter will ignore the second request!
A test client for urlshorter and docker-compose.yaml file can be found here
Content type
Image
Digest
Size
22.6 MB
Last updated
almost 8 years ago
docker pull mengluo668/urlshorter