GithubHelp home page GithubHelp logo

idempotency's Introduction

Laravel Idempotency

Latest Version on Packagist Software License Total Downloads

A super simple, customisable and automatically registering middleware to help you ensure your requests are Idempotent when it’s required.

Inspired by the guys at Stripe https://stripe.com/blog/idempotency and the realisation of how important this little feature is I mocked up this package.

Features

The idempotency layer compares incoming parameters to those of the original request and errors unless they're the same to prevent accidental misuse.

Once installed you can do stuff like this:

// Adding idempotency layer to a route
Route::post('hello-world', function() {
    // stuff
})->middleware('idempotent');

Installation

You can install the package via composer:

composer require danielebuso/idempotency

Customization

You can publish the package config by running:

php artisan vendor:publish --provider="idempotency\ServiceProvider"
Key Default Description
IDEMPOTENCY_KEY Idempotency-Key The key name specified in request headers to look for
IDEMPOTENCY_TTL 3600 Specify the time (in minutes) that the request will be cached for. Defaults to 1 hour.

You can also customize idempotency methods to other than POST, however it should be noted that:

According to HTTP semantics, the PUT and DELETE verbs are idempotent, and the PUT verb in particular signifies that a target resource should be created or replaced entirely with the contents of a request’s payload.

idempotency's People

Contributors

danielebuso avatar

Stargazers

 avatar  avatar

Watchers

 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.