Code Monkey home page Code Monkey logo

akka-http-batch-api's Introduction

akka-http-batch-api

Sample Implementation of a batch api using Akka-Http

Uses spray-json for converting to and from JSON.

Sample Usage:

Without batch api - normal request:

$ curl -X POST -H 'Content-Type: application/json' http://localhost:9000/movie -d '{"t": "Inception", "plot": "short" }' | jq

{
  "Title": "Inception",
  "Year": "2010",
  "Director": "Christopher Nolan",
  "Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
  "Response": "True",
  "imdbRating": "8.8",
  "Released": "16 Jul 2010"
}

Note: jq is used to pretty print the json response

With batch api:

$ curl -X POST -H 'Content-Type: application/json' http://localhost:9000/batch -d '[{"method": "POST", "relative_url": "/movie", "body": "{\n\t\"t\": \"Inception\",\n\t\"plot\": \"short\"}"},{"method": "POST", "relative_url": "/movie", "body": "{\n\t\"t\": \"The Dark Knight\"}"}]' | jq

[
  {
    "code": 200,
    "headers": [],
    "body": "{\"Title\":\"Inception\",\"Year\":\"2010\",\"Director\":\"Christopher Nolan\",\"Plot\":\"A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.\",\"Response\":\"True\",\"imdbRating\":\"8.8\",\"Released\":\"16 Jul 2010\"}"
  },
  {
    "code": 200,
    "headers": [],
    "body": "{\"Title\":\"The Dark Knight\",\"Year\":\"2008\",\"Director\":\"Christopher Nolan\",\"Plot\":\"When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.\",\"Response\":\"True\",\"imdbRating\":\"9.0\",\"Released\":\"18 Jul 2008\"}"
  }
]

akka-http-batch-api's People

Watchers

 avatar  avatar

Forkers

hemanshupaliwa7

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.