command module
Version: v0.0.0-...-cd653ad Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 12 Imported by: 0



Build Status Go Report

Simple HTTP vote collection API service in Go

Table of Contents


Clone the repo (or install via go get) and build the project. A makefile has been included for convenience.

git clone
cd vote-collector

The vote collector simply logs votes to a Postgres database, therefore a running instance of the Postgres database is required as a dependency. The connection is configured via environment variables. See Configuration for more info.


First, copy .env.example to .env and modify accordingly. Postgres variables need to be configured to point to an accessible, running Postgres instance.

# config
cp .env.example .env
vi .env #  (edit accordingly)

# run
go run vote-collector

# -or-
go build


The vote collector uses environment variables for configuration. Variables are read from a .env file and can be overwritten by variables defined in the environment or directly passed to the process. See all available settings in .env.example.

Quick start

A docker-compose file is included for testing purposes, which also sets up a Postgres database.

cp .env.example .env
vi .env #  (edit accordingly)

docker-compose up

To verify:

curl -i
Generating a JWT

Some routes in the API are only available with authentication. These are the audit routes, which allow reading vote entries:

  • /allVotes
  • /validVotes

For these, a JWT token must be sent in the header (see in this repo). There is currently no authentication table or route, so this must be manually generated.

To generate the JWT token, you can use the JWT Debugger. Simply visit the site, adjust the payload data accordingly, and in place of your-256-bit-secret, use the value of $JWT_SECRET_KEY that you set in the .env file (can be any secret string). Then click the "Share JWT" button to retrieve the JWT. This is the value you should send in the header after "Authorization: Bearer ".

An example JWT token looks like:


Note that this is just an example and will not work with any production deployment.




Feel free to dive in! Open an issue or submit PRs.


MIT © Dash Core Group, Inc.


The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL