GithubHelp home page GithubHelp logo

keremgocen / fun-with-spark Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.18 MB

Java Spark Rest API example with Retrofit/Lombok and OkHttp cache

License: Apache License 2.0

Java 64.75% JavaScript 32.38% Dockerfile 2.87%

fun-with-spark's Introduction

fun-with-spark

Java Spark Rest API example with Retrofit/Lombok and OkHttp as request cache

Dependencies

Compile/Run using Maven on OS X

Install Maven via brew

brew install maven

Compile and generate executable JAR with dependencies

mvn package

java -jar target/app-1.0-SNAPSHOT-jar-with-dependencies.jar

Usage

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

Compile/Run using Docker

Pull

docker pull keremgocen/fun-with-spark

Run

docker run -d -p 4567:8000 keremgocen/fws

Usage

curl localhost:4567/api/recent_purchases/:username

Build

(only if you changed something and want to get a new image)

docker build -t .

Compile/Run via IntelliJ

  • 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

Maven Dependencies

  • 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

config.properties file

Settings below can be mofidied in config.properties file.

Target url for daw-api

external.base.url = http://74.50.59.155:6000/api/

Port setting for this app

internal.listen.port = 8000

Response cache eviction time (seconds)

cachecontrol.maxage = 120

Response Caching

Response caching is achieved through Retrofit/OkHttp client and by intercepting incoming responses from external daw-api.

See Caching in HTTP for more info.

API Reference

GET /api/recent_purchases/:username

  • 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"
    ]
  },
  .
  .
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.