This is a spring boot application.
mvn spring-boot:run
Server will listen at port 3000.
this can be changed via src/main/resources/application.properties
curl -i -H "x-api-key:c144ce49-a6fe-4781-ad40-78fc62f51ee9" "http://localhost:3000/search?city=Bangkok&sort=desc"
For adding an api key,add a entry to src/main/resources/apikeys.store
Newly added key will get global rate limit settings
global.window.sec=10
global.request.threshold=1
To override these setting add a entry to src/main/resources/apikeys.properties in following format.
${apikey}.window.sec=#{some value for rate limit window}
${apikey}.request.threshold=#{some request threshold for given window}
-
Application start point is com.vp.controllers.SearchWebService
-
API implementation is done via search method in above class.
-
For RateLimiting functionality please check com.vp.config.APIKEYSetting.apiPermission(String) , core logic of rate liming is present in com.vp.ratelimit.RateLimmiter Implementation is done using atomic counter and synchronized block for thread safety.
-
For any other clarification please email vijayparashar.eca@gmail.com