Categorygithub.com/RaphaelParment/ppio-api
modulepackage
0.0.0-20240506195119-2f8e8898da7f
Repository: https://github.com/raphaelparment/ppio-api.git
Documentation: pkg.go.dev

# README

PPio RESTful API

RESTful API written in Go with Echo.

Endpoints

URIMethodDescription
/matchesGETGet the full list of matches.
/matches/:idGETGet a specific match.
/matchesPOSTCreate a new match.

Infrastructure

# Start infrastructure containers
$ make infra-up

# Stop infrastructure containers
$ make infra-down

Run app from lab

# Start lab
$ make lab-up

# Stop lan
$ make lab-down

With running infrastructure and lab containers

# Login lab
$ docker exec -it ppio-lab sh
$ go run main.go

Connect to db from lab

$ docker exec -it ppio-lab sh
$ PGPASSWORD=dummy psql -h db -p 5432 -d ppio -U ppio

Query server

Get one match

# Getting match with id 1
$ curl http://localhost:9001/matches/1

Get all matches

$ curl http://localhost:9001/matches

Persist match

$ curl -d '{"player_one_id":1,"player_two_id":5,"result":{"winner_id":5,"loser_retired":false},"score":[{"player_one_score":11,"player_two_score":3},{"player_one_score":0,"player_two_score":11},{"player_one_score":8,"player_two_score":11}],"datetime":"2023-03-05 22:50:00"}' http://localhost:9001/matches