Skip to content
Simple rest promo code server in go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Go learning project. Simple implementation of a promo code generator and validator for giving reviewers access to in app purchase protected areas of an iOS app. Minimal query string based authentication and short, easy to type promo codes.

Uses MongoDB hosted via MongoHQ Heroku addon with mgo for persistence and gorilla/mux for routing.


To create a new promo code:


Outputs code as plain text, sans newline.

To redeem a promo code:


Outputs true or false sans newline.

To list valid and redeemed promo codes, visit:

Run Locally

Be sure mongodb is installed and running on default port (27017), then:

PORT=5000 MONGOHQ_URL=mongodb://localhost/promocodes MONGOHQ_DB_NAME=promocodes PROMOPW=password go run web.go


To create a Heroku instance with the Go Buildpack:

heroku create -b

Install the MongoHQ Addon:

heroku addons:add mongohq:sandbox

Set the following env vars:

heroku config:set PROMOPW=yourpassword MONGOHQ_DB_NAME=find-this-through-mongohq-web-interface MONGOHQ_URL=also-found-in-mongohq-web-interface

And push:

git push heroku master

Be sure to run go get after making any changes to recompile your binary.

You can’t perform that action at this time.