Fix image rate limit

This commit is contained in:
Felix Ableitner 2020-08-05 13:42:10 +02:00
parent 4e0a8f1ab8
commit a6f5e4e1de
2 changed files with 5 additions and 1 deletions

View file

@ -45,6 +45,10 @@ impl RateLimit {
self.kind(RateLimitType::Register) self.kind(RateLimitType::Register)
} }
pub fn image(&self) -> RateLimited {
self.kind(RateLimitType::Image)
}
fn kind(&self, type_: RateLimitType) -> RateLimited { fn kind(&self, type_: RateLimitType) -> RateLimited {
RateLimited { RateLimited {
rate_limiter: self.rate_limiter.clone(), rate_limiter: self.rate_limiter.clone(),

View file

@ -17,7 +17,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimit) {
.data(client) .data(client)
.service( .service(
web::resource("/pictrs/image") web::resource("/pictrs/image")
.wrap(rate_limit.message()) .wrap(rate_limit.image())
.route(web::post().to(upload)), .route(web::post().to(upload)),
) )
.service(web::resource("/pictrs/image/{filename}").route(web::get().to(full_res))) .service(web::resource("/pictrs/image/{filename}").route(web::get().to(full_res)))