8000 GitHub - Senshyi/whalebone
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Senshyi/whalebone

7949

Repository files navigation

Whalebone Assignment

A simple microservice which provides two endpoints.

Requirements

  • Go v1.23
  • Docker
  • Make (optional)

Setup

from project root copy .env-example into .env

cp .env-example .env

run one of the make commands (see the file for all option)

make run
make itest

or you can run it manually

go run cmd/api/main.go
go build -o main cmd/api/main.go

Run dockerized application

There is a docker file prepared in the project root.

build image:

docker build . -t whalebone-assignment

run the image:

docker run --rm --name go-whalebone-assignment --publish 8000:8000 --env-file .env whalebone-assignment

after that, the app will be available to localhost:8000

Examples

post request to save user:

curl -X POST http://localhost:8000/save -d'{
"id": "ae593b85-b9a2-4386-ad71-7b62287d7c24",
"name": "example name",
"email": "example@gmail.com",
"date_of_birth": "2020-01-01T12:12:34+00:00" }'

get request for user created above:

curl -X GET http://localhost:8000/ae593b85-b9a2-4386-ad71-7b62287d7c24

application is also "softly" validated so for example id is expected to be a valid uuid:

curl -X GET http://localhost:8000/ae593b85-b9a2-4386-ad71-7b62287d7c24
response:
{
    "error": "invalid id"
}
status: 400

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0