- Create and Run postgres docker container:
docker run --name some-postgres --publish 127.0.0.1:5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres- Clone this repo.
- Create schemas and populate test tables:
sbt run blog.utils.CreateTables
sbt 'test:runMain blog.PopulateTables'- sbt run Server class
Using browser :
GET /blog/?key=<asc|desc>&order=<createdat|editedat>- to show all posts, key and order to sort the resultGET /blog/:id- get post at specific id
With CURL :
POST /blog- add a new blog entry, JSON format
example:
curl -H 'Content-Type: application/json' -s -XPOST http://127.0.0.1:8080/blog -d '{"title": "book", "content": "content", "tags": ["a", "b"], "author": "someone"}'PUT /blog:id- update blog with entry
example:
curl -H 'Content-Type: application/json' -s -XPUT http://127.0.0.1:8080/blog/94 -d '{"title": "bookNew", "content": "contentNew", "tags": ["a", "c"], "author":"somenew"}'DELETE /blog:id- deletes a blog entry by an id (cannot if there are duplicate id's present)