Java Spark Rest API example with Retrofit/Lombok and OkHttp as request cache
brew install maven
mvn package
java -jar target/app-1.0-SNAPSHOT-jar-with-dependencies.jar
username
Generated users will be listed in console when you run the app, you can just use any of the listed names
curl localhost:8000/api/recent-purchases/:username
docker pull keremgocen/fun-with-spark
docker run -d -p 4567:8000 keremgocen/fws
curl localhost:4567/api/recent_purchases/:username
(only if you changed something and want to get a new image)
docker build -t .
- IntelliJ Community Edition
- Tested on version 2016.2.12
- Go to "File->Open" and choose "app" folder in this repository to open the IntelliJ project
- Build & Run as a Maven project
- spark-core - Lightweight REST framefork
- slf4j-simple - Spark dependency
- lombok - Automated boilerplate getter/setters for objects
- retrofit - Used to consume daw-api
- converter-gson - Used by retrofit for serializing objects
Settings below can be mofidied in config.properties
file.
external.base.url = http://74.50.59.155:6000/api/
internal.listen.port = 8000
cachecontrol.maxage = 120
Response caching is achieved through Retrofit/OkHttp client and by intercepting incoming responses from external daw-api.
See Caching in HTTP for more info.
-
params:
- username (string)
-
response (json): max number of recents first
[
{
"id": 602508,
"face": "t(-.-t)",
"size": 36,
"price": 3,
"recent": [
"Misael_Hilpert",
"Kathleen.Upton22",
"Novella94",
"Frida_Welch39"
]
},
.
.
]