GithubHelp home page GithubHelp logo

diegolopezcdm / stitch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aolarchive/stitch

0.0 2.0 0.0 59 KB

This library helps implement HTTP PATCH method on Web Resources exposed by Restful APIs. See README.md for more info

Java 100.00%

stitch's Introduction

Stitch Library

This library helps implement HTTP PATCH method on Web Resources exposed by Restful APIs.

Introduction to PATCH

Complex resources consist of multiple independent/interdependent sub-resources. Sending the entire resource every time with PUT request may become prohibitive (mobile)

To support the Api client in resource update, one option is to develop APIs that surface these sub resources with their own GET/PUT methods. Of course, now the service ends up with multiple APIs. If the sub resources are not truly independent, this option is not feasible.

HTTP has introduced a new method PATCH, that will allow incremental update of resources

Say, there is a resource /api/v1/ping-pong/player

{ "id" : 111, "name": "Super Awesome Player", "speed_calculation_mistake_factor" : 0.05 }

To update "speed_calculation_mistake_factor" using HTTP Patch, the body of request may look like

[ { "op": "update", "path": "/speed_calculation_mistake_factor", "value": 0.10 } ]

On Success, typical response would be

200 OK -or- 204 No Content

With optional Content-Location header pointing to the resource.

Typical Operations

Typical operations used with PATCH include add, remove, update, replace, copy, test

Library Specific Information

Operations supported

  • add
  • replace
  • remove

Paths

Paths are evaluated as JSON Pointers [2].

E.g.

  1. With json document { "foo": ["abc", "efgh] } path "/foo/0" evalutes to "abc"

  2. With json document { "foo": { "0": 100, "xyz": 200 } } path "/f00/0" evaluates to 100

Getting Started

To get started with the library, see Library README.md

Multiple examples are provided the stitch-library-examples module. See Examples README.md.

References

[1] IETF JSON Patch - https://tools.ietf.org/html/draft-ietf-appsawg-json-patch-10

[2] IETF JSON Pointer - https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07

stitch's People

Watchers

James Cloos avatar  avatar

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.