Sign inSign up

outofcoffee/httphc

By outofcoffee

•Updated over 4 years ago

Simple HTTP hit counter

Image
0

2.4K

outofcoffee/httphc repository overview

⁠httphc - Simple HTTP hit counter

Run with Docker Compose:

docker-compose up

⁠Usage

Increment counter:

curl -X PUT http://localhost:7777/hits/foo

{
  "hits": 4,
  "lastActive": 1551839323
}

Get counter:

curl http://localhost:7777/hits/foo

{
  "hits": 4,
  "lastActive": 1551839323
}

Get all counters:

curl http://localhost:7777/hits

{
  "bar": {
    "hits": 3,
    "lastActive": 1551838816
  },
  "baz": {
    "hits": 1,
    "lastActive": 1551838818
  }
}

⁠Configuration

The following environment variables are supported:

NamePurposeDefaultExample
PORTHTTP port on which to listen77777777
REDIS_HOSTBackend Redis store hostlocalhost10.0.0.1
REDIS_PORTBackend Redis store port63796379

⁠Build

Prerequisites:

  • Go 1.17+

Build:

go build

Run:

./httphc

⁠Testing

Test different configurations using Docker Compose.

⁠GCP Datastore
docker-compose up --force-recreate --build httphc-datastore

This implementation requires that you set the following environment variables:

  • STORE_IMPL=datastore
  • DATASTORE_PROJECT_ID=... # e.g. myproject-123456
  • DATASTORE_CREDENTIALS_DIR=... # e.g. /dir/containing/service/account/file/
⁠GCP Firestore
docker-compose up --force-recreate --build httphc-firestore

This implementation requires that you set the following environment variables:

  • STORE_IMPL=firestore
  • FIRESTORE_CREDENTIALS_DIR=... # e.g. /dir/containing/service/account/file/
⁠Redis
docker-compose up --force-recreate --build httphc-redis redis

Note: this also starts a local Redis container.

This implementation requires that you set the following environment variables:

  • STORE_IMPL=redis
  • REDIS_HOST=... # e.g. localhost

Optional:

  • REDIS_PORT=... # e.g. 6379

Tag summary

Content type

Image

Digest

Size

35.7 MB

Last updated

over 4 years ago

docker pull outofcoffee/httphc