feat(api): update rust deps, move /private/meta endpoint to rust-api

This commit is contained in:
alyssa 2024-06-16 21:56:14 +09:00
parent f14c421e23
commit e415c6704f
20 changed files with 1835 additions and 244 deletions

View file

@ -1,5 +1,6 @@
use axum::{
http::{HeaderMap, HeaderValue, Method, Request, StatusCode},
extract::Request,
http::{HeaderMap, HeaderValue, Method, StatusCode},
middleware::Next,
response::{IntoResponse, Response},
};
@ -14,7 +15,7 @@ fn add_cors_headers(headers: &mut HeaderMap) {
headers.append("Access-Control-Max-Age", HeaderValue::from_static("86400"));
}
pub async fn cors<B>(request: Request<B>, next: Next<B>) -> Response {
pub async fn cors(request: Request, next: Next) -> Response {
let mut response = if request.method() == Method::OPTIONS {
StatusCode::OK.into_response()
} else {

View file

@ -1,6 +1,7 @@
use axum::{
extract::MatchedPath,
http::{Request, StatusCode},
extract::Request,
http::StatusCode,
middleware::Next,
response::{IntoResponse, Response},
};
@ -16,7 +17,7 @@ fn is_trying_to_use_v1_path_on_v2(path: &str) -> bool {
|| path == "/v2/m"
}
pub async fn ignore_invalid_routes<B>(request: Request<B>, next: Next<B>) -> Response {
pub async fn ignore_invalid_routes(request: Request, next: Next) -> Response {
let path = request
.extensions()
.get::<MatchedPath>()

View file

@ -1,6 +1,6 @@
use std::time::Instant;
use axum::{extract::MatchedPath, http::Request, middleware::Next, response::Response};
use axum::{extract::MatchedPath, extract::Request, middleware::Next, response::Response};
use metrics::histogram;
use tracing::{info, span, warn, Instrument, Level};
@ -10,7 +10,7 @@ use crate::util::header_or_unknown;
// todo: change as necessary
const MIN_LOG_TIME: u128 = 2_000;
pub async fn logger<B>(request: Request<B>, next: Next<B>) -> Response {
pub async fn logger(request: Request, next: Next) -> Response {
let method = request.method().clone();
let request_id = header_or_unknown(request.headers().get("Fly-Request-Id"));

View file

@ -1,13 +1,12 @@
use std::time::{Duration, SystemTime};
use axum::http::{HeaderValue, StatusCode};
use axum::{
extract::State,
http::Request,
extract::{Request, State},
middleware::{FromFnLayer, Next},
response::Response,
};
use fred::{pool::RedisPool, prelude::LuaInterface, types::ReconnectPolicy, util::sha1_hash};
use http::{HeaderValue, StatusCode};
use metrics::increment_counter;
use tracing::{debug, error, info, warn};
@ -55,10 +54,10 @@ pub fn ratelimiter<F, T>(f: F) -> FromFnLayer<F, Option<RedisPool>, T> {
axum::middleware::from_fn_with_state(redis, f)
}
pub async fn do_request_ratelimited<B>(
pub async fn do_request_ratelimited(
State(redis): State<Option<RedisPool>>,
request: Request<B>,
next: Next<B>,
request: Request,
next: Next,
) -> Response {
if let Some(redis) = redis {
let headers = request.headers().clone();