# Idempotent Library for Spring MVC **Repository Path**: booting/idem4j ## Basic Information - **Project Name**: Idempotent Library for Spring MVC - **Description**: Spring Boot based idempotent library - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-05-19 - **Last Updated**: 2022-06-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Idempotent Library for Spring MVC [![Booting/Idempotent Library for Spring MVC](https://gitee.com/booting/idem4j/widgets/widget_card.svg?colors=393222,ebdfc1,fffae5,d8ca9f,393222,a28b40)](https://gitee.com/booting/idem4j) *Jira* address : https://issues.sonatype.org/browse/OSSRH-58103 ## Usage Just put `idem4j-core` into your `pom.xml` as following: ```xml com.gitee.booting idem4j-core VERSION ``` > Please check [release](https://gitee.com/booting/idem4j/releases) for list of `VERSION`s. To make it work, a `RedisTemplate` instance and proper mapping patterns are required. A valid configuration perhaps looks like as following: ```yaml idem4j: mapping: '[/api/v1/hello]': # generator: () -> java.util.UUID.randomUUID().toString() fail-on-absent: true spring: data: redis: host: localhost port: 6379 ``` Which means only `/api/v1/hello` should keep idempotent. Please remember, keys of `idem4j.mapping` will be treated as regular expressions, which will be applied to `Pattern.compile()` to generate pre-compiled instances. As a example, key `/api/v1/.*` means all APIs start with `/api/v1` will be checked to keep them idempotent. A valid request (such as `/api/v1/hello`) should have a proper header named as `X-Idempotent-Token` with a fresh token generated by calling API `/api/v1/idem4j-token` (`data` field of the response, valid in `3` minutes) as its value. Otherwise, `403` response will be returned. > You do not need to specify `idem4j.mapping.[key].generator` if `UUID.randomUUID().toString()`(the default idempotent token generator) is enough. ## How to make a contribute? - `fork` this repository - Do whatever update as you will - Commit your changes - Create a new merge request - No more action is required