-
Notifications
You must be signed in to change notification settings - Fork 0
kriskalwala/TestingScalaTwo
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Here is an example to test RESTfull web service (limited value to be posted - soon will be full vector) - need to re-map accordingly Reads in the controller
# to run app :
Roses-MacBook-Air:AdvertONE roseair$ ./activator run
[info] Loading project definition from /Applications/advertONE/project
[info] Set current project to scala-play-rest-example (in build file:/Applications/advertONE/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
#testing web service:
curl -X POST http://localhost:9000/adverts -H "Content-Type: application/json" -d "{\"title\": \"Jaguar XT\"}"
curl -X GET http://localhost:9000/adverts/1
curl -H "Content-Type: application/json" -X PUT http://localhost:9000/adverts/1 -d "{\"title\": \"Fiat125\"}"
curl -X DELETE http://localhost:9000/adverts/1
#example:
#<POSTING JAGUAR>
curl -X POST http://localhost:9000/adverts -H "Content-Type: application/json" -d "{\"title\": \"Jaguar XT\", \"fuel\": \"GAS\", \"price\": \"125000\", \"issnew\": \"YES\"}"
landing in ADVERT REPOSITORY
created Advert: Advert(Some(1),Jaguar XT)
POST done
#<CHECK WHAT WAS POSTED>
curl -X GET http://localhost:9000/adverts/1
{"id":1,"title":"Jaguar XT"}Roses-MacBook-Air:Applications roseair$
<CHANGE THE CARS>
curl -H "Content-Type: application/json" -X PUT http://localhost:9000/adverts/1 -d "{\"title\": \"Fiat125\", \"fuel\": \"GAS\", \"price\": \"125000\", \"issnew\": \"YES\"}"
#<CHANGED JAGUAR TO FIAT>
curl -X GET http://localhost:9000/adverts/1
{"id":1,"title":"Fiat125"}
#<DELETING id=1>
curl -X DELETE http://localhost:9000/adverts/1
#<CHECK IF EMPTY>
curl -X GET http://localhost:9000/adverts/1
<YES>
About
Excerising backend Scala app to present RESTful web service in Scala
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published