omgftw / GoLangApiExample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stock API Example App

Configuration

Configuration is done via environment variables:

  • BASEURL: The Base URL for the Stock API to use
  • APIKEY: The API key to use
  • SYMBOL: The stock ticker symbol to use
  • NDAYS: the amount of days to return via a GET request

Usage

cd ~/go/src/
git clone https://github.com/omgftw/GoLangApiExample.git
go get
go run main.go

Docker

Building

docker build -t stock-api .

Run locally

Set an API key

APIKEY=YOUR_KEY_HERE

Run Docker Hub image:

docker run --rm -e APIKEY="$APIKEY" -p 8080:8080 omgftw/stock-api

Run local image:

docker run --rm -e APIKEY="$APIKEY" -p 8080:8080 stock-api 

Open http://127.0.0.1:8080 in your browser

Kubernetes

kubectl create secret generic stock-api-secret --from-literal=APIKEY='YOUR_KEY_HERE' 
kubectl apply -f kubernetes/

It can be accessed using your kubernetes url at the path /stock-api

Example: http://192.168.64.3/stock-api

About


Languages

Language:Go 90.0%Language:Dockerfile 10.0%