Simple soccer REST API with Echo & MongoDB
This project is using go module, so you don't have to clone it inside GOPATH directory.
# Clone the repository
git clone https://github.com/yezarela/go-soccer.git
# Navigate to project directory
cd go-soccer
# Install dependencies
make deps
# Run the application
make run
# Hit the endpoint
curl localhost:1323/teams
If you want to use your own mongodb uri, you can update the .env file with your own mongodb uri
make test
These are the endpoints available from the app
Returns list of teams
Show example response
{
"meta": {
"code": 200
},
"data": [
{
"id": "5f6a5d6129b2289c40b7444b",
"name": "AC Milan 2",
"description": "some-description",
"location": "Italy",
"players": [
{
"id": "5f6a5d6129b2289c40b74448",
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward",
"created_at": "2020-09-22T20:24:01.872Z"
}
],
"created_at": "2020-09-22T20:24:01.846Z"
}
]
}
Returns a team by id
Show example response
{
"meta": {
"code": 200
},
"data": {
"id": "5f6a5d6129b2289c40b7444b",
"name": "AC Milan 2",
"description": "some-description",
"location": "Italy",
"players": [
{
"id": "5f6a5d6129b2289c40b74448",
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward",
"created_at": "2020-09-22T20:24:01.872Z"
}
],
"created_at": "2020-09-22T20:24:01.846Z"
}
}
Creates a new team and it's players
This request requires body payload, you can find the example below.
Show example payload
{
"name": "AC Milan 2",
"description": "some-description",
"location": "Italy",
"players": [
{
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward"
}
]
}
The request will return the created data in JSON response like this:
Show example response
{
"meta": {
"code": 200
},
"data": {
"id": "5f6a5d6129b2289c40b7444b",
"name": "AC Milan 2",
"description": "some-description",
"location": "Italy",
"players": [
{
"id": "5f6a5d6129b2289c40b74448",
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward",
"created_at": "2020-09-22T20:24:01.872Z"
}
],
"created_at": "2020-09-22T20:24:01.846Z"
}
}
Returns list of players
Show example response
{
"meta": {
"code": 200
},
"data": [
{
"id": "5f6a5c31d7c451c369802c02",
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward",
"created_at": "2020-09-22T20:18:57.957Z"
}
]
}
Returns a player by id
Show example response
{
"meta": {
"code": 200
},
"data": {
"id": "5f6a5c31d7c451c369802c02",
"name": "John Doe 1",
"nickname": "Lolo",
"position": "forward",
"created_at": "2020-09-22T20:18:57.957Z"
}
}