A tiny Go and Gin demo API server with an in-memory key/value map.
- Go 1.26.2
- Gin v1.12.0
go run ./cmd/serverThe server listens on PORT when set by Cloud Run, otherwise 8080 locally.
Store text under an id:
curl -i -X POST http://localhost:8080/foo \
-H 'Content-Type: text/plain' \
--data 'bar'Read text by id:
curl -i http://localhost:8080/fooMissing ids return 404.
go test ./...docker build -t interview-api-server .
docker run --rm -p 8080:8080 interview-api-serverThe default Cloud Run region is Melbourne: australia-southeast2.
The container image is stored in the interview Artifact Registry repository:
image: australia-southeast2-docker.pkg.dev/interview-495207/interview/interview-api-server:latestBuild and push the image:
gcloud builds submit \
--tag australia-southeast2-docker.pkg.dev/interview-495207/interview/interview-api-server:latestDeploy from the template:
gcloud run services replace deploy/cloudrun.yaml --region australia-southeast2The template allows public unauthenticated access with Cloud Run's invoker IAM check disabled.
Or deploy directly:
gcloud run deploy interview-api-server \
--image australia-southeast2-docker.pkg.dev/interview-495207/interview/interview-api-server:latest \
--region australia-southeast2 \
--no-invoker-iam-check