go get



This is a simple gateway written using Golang. It is currently setup to talk to one of our microservices, auth-server.

Installation in Docker

To run the api gateway, you need to install Docker to your machine. Follow instructions to install Docker here.

Mac and Windows Users:
If you are using Mac OS X or Windows, make sure to run the Docker Quickstart Terminal.

All that's left is to build and run your container. Here are some common commands to help you along:

// Build your current directory into an image
docker build --tag=apigoteway .

// Run a new docker container using an image
docker run --name=apigoteway --detach=true --publish=4000:4000 apigoteway

// List all containers
docker ps

// Kill a running container
docker stop apigoteway

// Remove a container
docker rm apigoteway

Mac and Windows Users:
Localhost will not work when trying to access your container from your web browser. Run this command to find the ip address of the default VM:

docker-machine ip default

Setting up your workspace

See linux-alt.txt for alternate instructions.

Follow instructions to install golang here:
You will need to create a working directory for use with your golang projects and create a GOPATH that points to it. For our purposes our directory is called gospace.

"Go" (ha) to your gospace and follow these commands:

go get
Note: go get can be used in any directory and will stay relative to GOPATH. There are also other third-party imports that will be incorporated over time. One way to find them all is to use:
grep -rsh 'github' $GOPATH/src/* | sed -e 's/^[ \t]*//'

Running the API gateway

At this point you are ready to run our gateway!

go run main.go

Testing Information

Test main and all subpackages (subdirectories) with:

go test ./...

Create a test for somefile.go named somefile_test.go in same directory. An example, apigateway_test.go, is available using assert of JSON structs to test HTTP handler functions.