From 2cc33cc3e8bcd53d2861e8f3aa78a3d587fd3d74 Mon Sep 17 00:00:00 2001 From: Paul Zinselmeyer Date: Tue, 19 Dec 2023 12:13:48 +0100 Subject: [PATCH] route permission change --- server/src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 8140145..d811683 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -7,7 +7,7 @@ use duration_str::{deserialize_option_duration, parse_std}; use jwt::JwtApplication; use prometheus_client::{ encoding::EncodeLabelSet, - metrics::{counter::Counter, family::Family, gauge::Gauge, histogram::Histogram}, + metrics::{counter::Counter, family::Family, gauge::Gauge}, registry::{Registry, Unit}, }; use sailfish::TemplateOnce; @@ -15,7 +15,7 @@ use std::{ borrow::Borrow, env, str::FromStr, - sync::{atomic::AtomicU64, Arc}, + sync::Arc, time::{Duration, SystemTime, UNIX_EPOCH}, }; use tower_http::services::ServeDir; @@ -25,8 +25,7 @@ use tower_sessions::{cookie::SameSite, MemoryStore, SessionManagerLayer}; use axum::{ async_trait, - body::{Body, HttpBody}, - debug_handler, + body::Body, error_handling::HandleErrorLayer, extract::{FromRef, FromRequest, Multipart, Path, Query, State}, http::{ @@ -34,11 +33,10 @@ use axum::{ HeaderMap, HeaderValue, Request, StatusCode, Uri, }, response::{Html, IntoResponse, Redirect, Response}, - routing::{get, post}, + routing::{delete, get, post}, BoxError, Router, }; -use bytes::Bytes; use chacha20::{ cipher::{KeyIvInit, StreamCipher}, ChaCha20, @@ -210,10 +208,10 @@ async fn main() { let app = Router::new() .route("/", get(get_index)) - .route("/:id", post(upload_bin).put(upload_bin).delete(delete_bin)) + .route("/:id", delete(delete_bin)) .route("/:id/delete", get(delete_bin_interactive).post(delete_bin)) .layer(oidc_login_service) - .route("/:id", get(get_item)) + .route("/:id", get(get_item).post(upload_bin).put(upload_bin)) .route("/metrics", get(metrics)) .nest_service("/static", ServeDir::new("static")) .with_state(state)