- Change config in config/config.yaml, if necessary
go build cmd/app/app.go
./app --storage=in-memory
# or
./app --storage=postgres
# default storage: in-memory
docker build -t shorter .
# ports should be similar with ones in config/config.yaml
docker run -p 8080:8080 -p 8081:8081 shorter in-memory
# or
docker run -p 8080:8080 -p 8081:8081 shorter postgres
Base url(Host and Port) for grcp you can find in config/config.yaml
Endpoints you can find in api/shortener_v1/shortener.proto
Base url(Host and Port) for HTTP you can find in config/config.yaml
Endpoints:
- GET - redirect to original page
/{identifier}
- POST - create short url
/?url="http://example.com"
Service just generate random string of character until find unique. I'm not using hashing algs because there might be collisions.