A high-throughput URL shortener microservice built with Go.
- gRPC for communication
- Redis store out of the box
- Fast & simple
See start-dev.sh for a complete list of available environmental variables. To use in a docker container, we have an image here.
Dwarf will deliver a 301 redirection to the destination URL or redirect to the fallback
URL specified with NOTFOUND_REDIRECT_URL
.
You must communicate with dwarf via gRPC in order to generate new shortened URLs.
service Dwarf {
rpc Create(CreateRequest) returns (CreateResponse) {}
}
message CreateRequest {
repeated string urls = 1;
}
message CreateResponse {
repeated string urls = 2;
}
Your response will return a set of shortened urls in the same order that they were sent:
// -> Request
{ "urls": ["http://long-url.com/1", "http://long-url.com/2"] }
// -> Response
{ "urls": ["http://sh.ort/Mp", "http://sh.ort/uJ"] }
To generate short urls, use a gRPC client such as this node client.
- Protobuf/gRPC is required.
- Go & dep
Spin up an instance of redis with:
docker run -p "6379:6379" --rm --name dwarf-redis redis:4-alpine
go test github.com/LevInteractive/dwarf/ -v
Note that the tests rely on a running redis instance.