Skip to content

ccellado/rest-crud-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API test application

Installation

  1. Create and Run postgres docker container:
docker run --name some-postgres --publish 127.0.0.1:5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
  1. Clone this repo.
  2. Create schemas and populate test tables:
sbt run blog.utils.CreateTables
sbt 'test:runMain blog.PopulateTables'
  1. sbt run Server class

Testing REST API

Using browser :

  1. GET /blog/?key=<asc|desc>&order=<createdat|editedat> - to show all posts, key and order to sort the result
  2. GET /blog/:id - get post at specific id

With CURL :

  1. 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"}'
  1. 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"}'
  1. DELETE /blog:id - deletes a blog entry by an id (cannot if there are duplicate id's present)

Releases

No releases published

Packages

No packages published

Languages