mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
@@ -8,7 +8,7 @@
|
||||
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{extractor_middleware, ContentLengthLimit, Extension, RequestParts, UrlParams},
|
||||
extract::{extractor_middleware, ContentLengthLimit, Extension, Path, RequestParts},
|
||||
prelude::*,
|
||||
response::IntoResponse,
|
||||
routing::BoxRoute,
|
||||
@@ -79,7 +79,7 @@ struct State {
|
||||
}
|
||||
|
||||
async fn kv_get(
|
||||
UrlParams((key,)): UrlParams<(String,)>,
|
||||
Path(key): Path<String>,
|
||||
Extension(state): Extension<SharedState>,
|
||||
) -> Result<Bytes, StatusCode> {
|
||||
let db = &state.read().unwrap().db;
|
||||
@@ -92,7 +92,7 @@ async fn kv_get(
|
||||
}
|
||||
|
||||
async fn kv_set(
|
||||
UrlParams((key,)): UrlParams<(String,)>,
|
||||
Path(key): Path<String>,
|
||||
ContentLengthLimit(bytes): ContentLengthLimit<Bytes, { 1024 * 5_000 }>, // ~5mb
|
||||
Extension(state): Extension<SharedState>,
|
||||
) {
|
||||
@@ -113,10 +113,7 @@ fn admin_routes() -> BoxRoute<hyper::Body> {
|
||||
state.write().unwrap().db.clear();
|
||||
}
|
||||
|
||||
async fn remove_key(
|
||||
UrlParams((key,)): UrlParams<(String,)>,
|
||||
Extension(state): Extension<SharedState>,
|
||||
) {
|
||||
async fn remove_key(Path(key): Path<String>, Extension(state): Extension<SharedState>) {
|
||||
state.write().unwrap().db.remove(&key);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user