Skip to content

codimiracle/request-identifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

request-identifier

prevents form or request multi-submits.

Installation

includes dependency in pom.xml

notes: don't publish maven central yet, you can install by mvn install and then using following pom dependency.

<dependency>
    <groupId>com.codimiracle.web</groupId>
    <artifactId>request-identifier</artifactId>
    <version>0.0.1-snapshot</version>
</dependency>

Feature

  • Request infrequent repeat
  • Request only once (based on redis)
  • Checking result and running custom logic (implements ResultHandler)

Usage

using @NonRepeatable annotate in controller layer:

  1. only once

    @NonRepeatable
    public String onlyOnce(String data) {
        return "Your submission is accepted.";
    }
  2. don't repeat in one seconds interval.

    @NonRepeatable(interval = NonRepeatable.DEFAULT_INTERVAL)
    public String defaultInterval(String data) {
        return "Your submission is accepted.";
    }
  3. custom interval

    @NonRepeatable(interval = 2000)
    public String customInterval(String data) {
        return "Your submission is accepted.";
    }
  4. using specified request parameter

    parameter value will retrieve from HttpServletRequest#getParameterValues();

    @GetMapping("/hello")
    @NonRepeatable(strategy = IdentifierStrategy.REQUEST_PARAMETER, parameterName = "request_id")
    public String customInterval(String data) {
        return "Your submission is accepted.";
    }
  5. using all parameters in request

    @GetMapping("/hi")
    @NonRepeatable(strategy = IdentifierStrategy.REQUEST_PARAMETER)
    public String customInterval(String data) {
        return "Your submission is accepted.";
    }

About

backend-componentized basic request repeat checking.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages