Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
pb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

dwarf

A high-throughput URL shortener microservice built with Go.

  • gRPC for communication
  • Redis store out of the box
  • Fast & simple

Usage

See start-dev.sh for a complete list of available environmental variables. To use in a docker container, we have an image here.

GET /{short-hash} -> 301 redirection

Dwarf will deliver a 301 redirection to the destination URL or redirect to the fallback URL specified with NOTFOUND_REDIRECT_URL.

Creating short links

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"] }

A dwarf gRPC client written with node.js

To generate short urls, use a gRPC client such as this node client.

Development

Redis Store

Spin up an instance of redis with:

docker run -p "6379:6379" --rm --name dwarf-redis redis:4-alpine

Testing

go test github.com/LevInteractive/dwarf/ -v

Note that the tests rely on a running redis instance.

About

A O(1) URL shortener microservice backed by redis and gRPC communication.

Topics

Resources

Releases

No releases published

Packages

No packages published