Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
unfiltered request throttler
Scala
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/main/scala/curbed
.gitignore
LICENSE
README.md
build.sbt

README.md

Curbed

Bottle requests with an unfiltered throttle

usage

Install as a filter in an unfiltered pipeline

basic in memory throttling

import unfiltered.response.ResponseString
import curbed._

object Server {
   def main(args: Array[String]) {
     unfiltered.jetty.Http.anylocal
      .filter(unfiltered.filter.Planify(new Throttle().intent))
      .filter(unfiltered.filter.Planify {
        case _ => ResponseString("ah ha")
      }).run
   }
}

basic in memory throttling with explicit maximum requests

import unfiltered.response.ResponseString
import curbed._

object Server {
   def main(args: Array[String]) {
     unfiltered.jetty.Http.anylocal
      .filter(unfiltered.filter.Planify(new Throttle(maxRequests = 100).intent))
      .filter(unfiltered.filter.Planify {
        case _ => ResponseString("ah ha")
      }).run
   }
}

basic in memory throttling with a daily request window

import unfiltered.response.ResponseString
import curbed._

object Server {
  def main(args: Array[String]) {
    unfiltered.jetty.Http.anylocal
      .filter(unfiltered.filter.Planify(new Throttle(window = new DailyWindow with IpKeyer).intent))
      .filter(unfiltered.filter.Planify {
        case _ => ResponseString("ah ha")
      }).run
  }
}

TODO

Doug Tangren (softprops) 2010-2011

Something went wrong with that request. Please try again.