ctb_io_webui/extractors/request_uri.rs
1// SPDX-License-Identifier: AGPL-3.0-or-later
2/*
3This file is part of Collective Toolbox, a database and document workspace and utilities.
4Copyright (C) 2026 Collective Toolbox Developers
5Contact: info@collectivetoolbox.com
6
7This program is free software: you can redistribute it and/or modify it under
8the terms of the GNU Affero General Public License as published by the Free
9Software Foundation, either version 3 of the License, or (at your option) any
10later version.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
15
16You should have received a copy of the GNU Affero General Public License along
17with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20//! URI path and query string extractor for incoming requests.
21
22use axum::extract::FromRequestParts;
23use http::StatusCode;
24
25/// Extractor for the request URI as a string.
26pub struct RequestUri(pub String);
27
28impl<S> FromRequestParts<S> for RequestUri
29where
30 S: Send + Sync,
31{
32 type Rejection = StatusCode;
33 async fn from_request_parts(
34 parts: &mut axum::http::request::Parts,
35 _state: &S,
36 ) -> Result<Self, Self::Rejection> {
37 Ok(RequestUri(parts.uri.to_string()))
38 }
39}