Random Facts is a RESTful API service consisting of PostgreSQL database that stores random facts and golang API service that handles POST, GET and PUT requests.
{
"title": "Lorem Ipsum",
"description": "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
"links": [
"Loremipsum.com/Lorem"
]
}
Consists of 404 (Not Found)
Header and JSON body:
{
"status": 400,
"message": "Some error message"
}
Consists of 302 (Found)
Header and JSON body:
{
"id": $passed_id
"title": "Lorem Ipsum",
"description": "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknownprinter took a galley of type and scrambled it to make a type specimen book."
"links": [
"Lorem.com/Lorem",
"Ipsum.net/Ipsum"
]
}
Consists of 404 (Not Found)
Header and JSON body:
{
"status": 404,
"message": "Some error message"
}
{
"facts": [
{
"title": "A diabolo, qui est simia dei",
"description": "English equivalent: Where god has a church the devil will have his chapel.",
"links": [
"https://en.wikiquote.org/wiki/Latin_proverbs"
]
},
{
"title": "Some facts may not include Links",
"description": "And you should be fine with that.",
}
]
}
Consists of 201 (Created)
Header and JSON body of inserted IDs:
{
"ids": [
7,
8,
9
]
}
Consists of 400 (Bad Request)
Header and JSON body:
{
"status": 400,
"message": "Unable to POST error message"
}
{
"id": 42,
"title": "Abyssus abyssum invocat.",
"description": "English equivalent: Deep calls to deep. From the Bible, Psalm 42:7.",
"links": [
"https://en.wikiquote.org/wiki/Latin_proverbs",
"https://www.bible.com/en-GB/bible/116/psa.42.7"
]
}
Consists of 302 (Found)
Header and empty JSON body:
{}
Consists of 400 (Bad ERequest)
Header and JSON body:
{
"status": 400,
"message": "Some error message"
}
- git clone this repo
git clone https://github.com/hyonosake/Random-Facts-Server/ && cd Random-Facts-Server/
- Use docker-compose to build containers with PostgreSQL and API service
docker-compose up
- Open your browser or API-testing app, enter
localhost:8080/fact
and make some requests!
tests folder provides json-exported Queries from Postman.