1
0
Fork 0
icann-rdap/icann-rdap-srv/src/rdap/autnum.rs
Daniel Baumann b06d3acde8
Adding upstream version 0.0.22.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-05-08 18:41:54 +02:00

24 lines
683 B
Rust

use axum::{
extract::{Path, State},
response::Response,
};
use crate::{error::RdapServerError, rdap::response::ResponseUtil, server::DynServiceState};
use super::ToBootStrap;
/// Gets an autnum object by the number path.
#[axum_macros::debug_handler]
#[tracing::instrument(level = "debug")]
pub(crate) async fn autnum_by_num(
Path(as_num): Path<u32>,
state: State<DynServiceState>,
) -> Result<Response, RdapServerError> {
let storage = state.get_storage().await?;
let autnum = storage.get_autnum_by_num(as_num).await?;
Ok(if state.get_bootstrap() {
autnum.to_autnum_bootstrap(as_num).response()
} else {
autnum.response()
})
}