mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-29 15:51:20 +00:00
move message rate limit
This commit is contained in:
parent
48e817bacc
commit
12ef9a0771
2 changed files with 9 additions and 36 deletions
|
@ -166,28 +166,19 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
// Site
|
// Site
|
||||||
.service(
|
.service(
|
||||||
web::scope("/site")
|
web::scope("/site")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(get_site))
|
.route("", web::get().to(get_site))
|
||||||
// Admin Actions
|
// Admin Actions
|
||||||
.route("", web::post().to(create_site))
|
.route("", web::post().to(create_site))
|
||||||
.route("", web::put().to(update_site))
|
.route("", web::put().to(update_site))
|
||||||
.route("/block", web::post().to(block_instance)),
|
.route("/block", web::post().to(block_instance)),
|
||||||
)
|
)
|
||||||
.service(
|
.route("/modlog", web::get().to(get_mod_log))
|
||||||
web::resource("/modlog")
|
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route(web::get().to(get_mod_log)),
|
|
||||||
)
|
|
||||||
.service(
|
.service(
|
||||||
web::resource("/search")
|
web::resource("/search")
|
||||||
.wrap(rate_limit.search())
|
.wrap(rate_limit.search())
|
||||||
.route(web::get().to(search)),
|
.route(web::get().to(search)),
|
||||||
)
|
)
|
||||||
.service(
|
.route("/resolve_object", web::get().to(resolve_object))
|
||||||
web::resource("/resolve_object")
|
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route(web::get().to(resolve_object)),
|
|
||||||
)
|
|
||||||
// Community
|
// Community
|
||||||
.service(
|
.service(
|
||||||
web::resource("/community")
|
web::resource("/community")
|
||||||
|
@ -197,7 +188,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/community")
|
web::scope("/community")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(get_community))
|
.route("", web::get().to(get_community))
|
||||||
.route("", web::put().to(update_community))
|
.route("", web::put().to(update_community))
|
||||||
.route("/random", web::get().to(get_random_community))
|
.route("/random", web::get().to(get_random_community))
|
||||||
|
@ -213,16 +203,14 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
.route("/mod", web::post().to(add_mod_to_community))
|
.route("/mod", web::post().to(add_mod_to_community))
|
||||||
.service(
|
.service(
|
||||||
web::scope("/pending_follows")
|
web::scope("/pending_follows")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("/count", web::get().to(get_pending_follows_count))
|
.route("/count", web::get().to(get_pending_follows_count))
|
||||||
.route("/list", web::get().to(get_pending_follows_list))
|
.route("/list", web::get().to(get_pending_follows_list))
|
||||||
.route("/approve", web::post().to(post_pending_follows_approve)),
|
.route("/approve", web::post().to(post_pending_follows_approve)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.service(
|
.route(
|
||||||
web::scope("/federated_instances")
|
"/federated_instances",
|
||||||
.wrap(rate_limit.message())
|
web::get().to(get_federated_instances),
|
||||||
.route("", web::get().to(get_federated_instances)),
|
|
||||||
)
|
)
|
||||||
// Post
|
// Post
|
||||||
.service(
|
.service(
|
||||||
|
@ -234,7 +222,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/post")
|
web::scope("/post")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(get_post))
|
.route("", web::get().to(get_post))
|
||||||
.route("", web::put().to(update_post))
|
.route("", web::put().to(update_post))
|
||||||
.route("/delete", web::post().to(delete_post))
|
.route("/delete", web::post().to(delete_post))
|
||||||
|
@ -263,7 +250,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/comment")
|
web::scope("/comment")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(get_comment))
|
.route("", web::get().to(get_comment))
|
||||||
.route("", web::put().to(update_comment))
|
.route("", web::put().to(update_comment))
|
||||||
.route("/delete", web::post().to(delete_comment))
|
.route("/delete", web::post().to(delete_comment))
|
||||||
|
@ -281,7 +267,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
// Private Message
|
// Private Message
|
||||||
.service(
|
.service(
|
||||||
web::scope("/private_message")
|
web::scope("/private_message")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("/list", web::get().to(get_private_message))
|
.route("/list", web::get().to(get_private_message))
|
||||||
.route("", web::post().to(create_private_message))
|
.route("", web::post().to(create_private_message))
|
||||||
.route("", web::put().to(update_private_message))
|
.route("", web::put().to(update_private_message))
|
||||||
|
@ -316,7 +301,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/account")
|
web::scope("/account")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("/list_media", web::get().to(list_media))
|
.route("/list_media", web::get().to(list_media))
|
||||||
.route("/mention", web::get().to(list_mentions))
|
.route("/mention", web::get().to(list_mentions))
|
||||||
.route("/replies", web::get().to(list_replies))
|
.route("/replies", web::get().to(list_replies))
|
||||||
|
@ -339,15 +323,10 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
.route("/validate_auth", web::get().to(validate_auth)),
|
.route("/validate_auth", web::get().to(validate_auth)),
|
||||||
)
|
)
|
||||||
// User actions
|
// User actions
|
||||||
.service(
|
.route("/user", web::get().to(read_person))
|
||||||
web::scope("/user")
|
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(read_person)),
|
|
||||||
)
|
|
||||||
// Admin Actions
|
// Admin Actions
|
||||||
.service(
|
.service(
|
||||||
web::scope("/admin")
|
web::scope("/admin")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("/add", web::post().to(add_admin))
|
.route("/add", web::post().to(add_admin))
|
||||||
.route(
|
.route(
|
||||||
"/registration_application/count",
|
"/registration_application/count",
|
||||||
|
@ -375,7 +354,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/tagline")
|
web::scope("/tagline")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::post().to(create_tagline))
|
.route("", web::post().to(create_tagline))
|
||||||
.route("", web::put().to(update_tagline))
|
.route("", web::put().to(update_tagline))
|
||||||
.route("/delete", web::post().to(delete_tagline))
|
.route("/delete", web::post().to(delete_tagline))
|
||||||
|
@ -387,7 +365,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/custom_emoji")
|
web::scope("/custom_emoji")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::post().to(create_custom_emoji))
|
.route("", web::post().to(create_custom_emoji))
|
||||||
.route("", web::put().to(update_custom_emoji))
|
.route("", web::put().to(update_custom_emoji))
|
||||||
.route("/delete", web::post().to(delete_custom_emoji))
|
.route("/delete", web::post().to(delete_custom_emoji))
|
||||||
|
@ -395,7 +372,6 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::scope("/oauth_provider")
|
web::scope("/oauth_provider")
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::post().to(create_oauth_provider))
|
.route("", web::post().to(create_oauth_provider))
|
||||||
.route("", web::put().to(update_oauth_provider))
|
.route("", web::put().to(update_oauth_provider))
|
||||||
.route("/delete", web::post().to(delete_oauth_provider)),
|
.route("/delete", web::post().to(delete_oauth_provider)),
|
||||||
|
@ -404,11 +380,7 @@ pub fn config(cfg: &mut web::ServiceConfig, rate_limit: &RateLimitCell) {
|
||||||
web::scope("/oauth")
|
web::scope("/oauth")
|
||||||
.wrap(rate_limit.register())
|
.wrap(rate_limit.register())
|
||||||
.route("/authenticate", web::post().to(authenticate_with_oauth)),
|
.route("/authenticate", web::post().to(authenticate_with_oauth)),
|
||||||
),
|
)
|
||||||
);
|
.route("/sitemap.xml", web::get().to(get_sitemap)),
|
||||||
cfg.service(
|
|
||||||
web::scope("/sitemap.xml")
|
|
||||||
.wrap(rate_limit.message())
|
|
||||||
.route("", web::get().to(get_sitemap)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,6 +297,7 @@ fn create_http_server(
|
||||||
let server = HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
let cors_config = cors_config(&settings);
|
let cors_config = cors_config(&settings);
|
||||||
let app = App::new()
|
let app = App::new()
|
||||||
|
.wrap(rate_limit_cell.message())
|
||||||
.wrap(middleware::Logger::new(
|
.wrap(middleware::Logger::new(
|
||||||
// This is the default log format save for the usage of %{r}a over %a to guarantee to
|
// This is the default log format save for the usage of %{r}a over %a to guarantee to
|
||||||
// record the client's (forwarded) IP and not the last peer address, since the latter is
|
// record the client's (forwarded) IP and not the last peer address, since the latter is
|
||||||
|
|
Loading…
Reference in a new issue