Skip to content

shamu00/interview-api-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interview API Server

A tiny Go and Gin demo API server with an in-memory key/value map.

Requirements

  • Go 1.26.2
  • Gin v1.12.0

Run Locally

go run ./cmd/server

The server listens on PORT when set by Cloud Run, otherwise 8080 locally.

API

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/foo

Missing ids return 404.

Test

go test ./...

Docker

docker build -t interview-api-server .
docker run --rm -p 8080:8080 interview-api-server

Deploy To Cloud Run

The 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:latest

Build and push the image:

gcloud builds submit \
  --tag australia-southeast2-docker.pkg.dev/interview-495207/interview/interview-api-server:latest

Deploy from the template:

gcloud run services replace deploy/cloudrun.yaml --region australia-southeast2

The 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors