Skip to content

Commit

Permalink
Move expression, Matcher from rate-limiter-annotation to rate-limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinomso Ikwuagwu committed Jan 2, 2024
1 parent 473a9d1 commit 332232b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,18 @@ __3. Annotate classes and/or methods.__
```java
package com.myapplicatioon.web.rest;

import io.github.poshjosh.ratelimiter.annotations.RateCondition;
import io.github.poshjosh.ratelimiter.util.Rate;
import io.github.poshjosh.ratelimiter.model.Rate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/my-resources")
public class MyResource {
@RestController @RequestMapping("/my-resources") public class MyResource {

// Only 25 calls per second for users in role GUEST
@Rate(permits=25, when="web.request.user.role=GUEST")
@GetMapping("/greet/{name}")
public ResponseEntity<String> greet(@PathVariable String name) {
@Rate(permits = 25, when = "web.request.user.role=GUEST") @GetMapping("/greet/{name}") public ResponseEntity<String> greet(
@PathVariable String name) {
return ResponseEntity.ok("Hello " + name);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.poshjosh.ratelimiter.web.spring;

import io.github.poshjosh.ratelimiter.util.Rates;
import io.github.poshjosh.ratelimiter.model.Rates;
import io.github.poshjosh.ratelimiter.web.core.util.RateLimitProperties;

import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.poshjosh.ratelimiter.web.spring.uri;

import io.github.poshjosh.ratelimiter.annotation.RateSource;
import io.github.poshjosh.ratelimiter.model.RateSource;
import io.github.poshjosh.ratelimiter.web.core.util.PathPatterns;
import io.github.poshjosh.ratelimiter.web.core.util.ResourceInfoProvider;
import org.springframework.web.bind.annotation.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.poshjosh.ratelimiter.web.spring.weblayertests;

import io.github.poshjosh.ratelimiter.BandwidthFactory;
import io.github.poshjosh.ratelimiter.bandwidths.BandwidthFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import io.github.poshjosh.ratelimiter.annotation.ElementId;
import io.github.poshjosh.ratelimiter.util.Operator;
import io.github.poshjosh.ratelimiter.util.Rate;
import io.github.poshjosh.ratelimiter.util.Rates;
import io.github.poshjosh.ratelimiter.model.Rate;
import io.github.poshjosh.ratelimiter.model.Rates;
import io.github.poshjosh.ratelimiter.web.core.ResourceLimiterRegistry;
import io.github.poshjosh.ratelimiter.web.spring.RateLimitPropertiesSpring;
import org.junit.jupiter.api.Test;
Expand Down

0 comments on commit 332232b

Please sign in to comment.