Sign inSign up

0x76/counter

By 0x76

Updated almost 6 years ago

Image
0

857

0x76/counter repository overview

Counter

Build Status Docker Build

Simple Go app for keeping count.

Running

The easiest way of trying this out is by using the docker image 0x76/counter like so:

docker run -p 8080:8080 0x76/counter

Now you can follow the Usage section, be aware that running counter like this is non-persistent.

Usage

The basic idea is that each path represents a key or counter which can be interacted with in a RESTful way.

Here is an example:

# First create the counter
curl -X POST localhost:8080/some/path
> { "/some/path": 0, "AccessKey": "acf38625-bc7b-4241-97be-55d4f20219f6" }

# Now we can increment it using the returned access key 
#   (the header of the response will also contain the key)
curl -X PUT -H "Authorization: Bearer acf38625-bc7b-4241-97be-55d4f20219f6" localhost:8080/some/path
> { "/some/path": 1 }

# Query it using GET
curl -X GET localhost:8080/some/path
> { "/some/path": 1 }

# We can also delete a counter if we want
curl -X DELETE -H "Authorization: Bearer acf38625-bc7b-4241-97be-55d4f20219f6" localhost:8080/some/path

# Now if we query it we'll get a 404 back
curl -X GET localhost:8080/some/path
> Counter not yet created

Configuration

Environment variable table
keyexample valuesdefault valuecomment
DBmemory, etcd, disk, redis or badgermemorythis selects which database to use
DBHOSTetcd1:2379,etcd2:2379,etcd3:2379UNSETaddress of database server(s) (if applicable)
DISKPATH/data, ./relative-dataUNSETwhere to store database data (if applicable)
ADDRESS:8080, 127.0.0.1:4242:8080address for webserver to listen on

Tag summary

Content type

Image

Digest

Size

6.1 MB

Last updated

almost 6 years ago

docker pull 0x76/counter