vecs: add trait + derive crates

This commit is contained in:
nym21
2025-10-04 23:38:54 +02:00
parent a6062d4c39
commit 5fde0101bf
16 changed files with 324 additions and 20 deletions

View File

@@ -35,7 +35,7 @@ struct TxResponse {
impl ApiExplorerRoutes for Router<AppState> {
fn add_api_explorer_routes(self) -> Self {
self.route(
"/api/address/{address}",
"/api/chain/address/{address}",
get(
async |Path(address): Path<String>, state: State<AppState>| -> Response {
let Ok(address) = Address::from_str(&address) else {
@@ -148,7 +148,7 @@ impl ApiExplorerRoutes for Router<AppState> {
),
)
.route(
"/api/tx/{txid}",
"/api/chain/tx/{txid}",
get(
async |Path(txid): Path<String>, state: State<AppState>| -> Response {
let Ok(txid) = bitcoin::Txid::from_str(&txid) else {

View File

@@ -35,8 +35,19 @@ impl ApiMetricsRoutes for Router<AppState> {
Json(app_state.interface.get_indexes()).into_response()
}),
)
.route(
"/api/metrics/list",
get(
async |State(app_state): State<AppState>,
Query(pagination): Query<PaginationParam>|
-> Response {
Json(app_state.interface.get_metrics(pagination)).into_response()
},
),
)
// TODO:
// .route(
// "/api/vecs/metrics",
// "/api/metrics/search",
// get(
// async |State(app_state): State<AppState>,
// Query(pagination): Query<PaginationParam>|
@@ -45,16 +56,6 @@ impl ApiMetricsRoutes for Router<AppState> {
// },
// ),
// )
// .route(
// "/api/vecs/index-to-metrics",
// get(
// async |State(app_state): State<AppState>,
// Query(paginated_index): Query<PaginatedIndexParam>|
// -> Response {
// Json(app_state.interface.get_index_to_vecids(paginated_index)).into_response()
// },
// ),
// )
.route(
"/api/metrics/{metric}",
get(
@@ -85,7 +86,7 @@ impl ApiMetricsRoutes for Router<AppState> {
),
)
// !!!
// DEPRECATED
// DEPRECATED: Do not use
// !!!
.route(
"/api/vecs/query",
@@ -100,7 +101,7 @@ impl ApiMetricsRoutes for Router<AppState> {
),
)
// !!!
// DEPRECATED
// DEPRECATED: Do not use
// !!!
.route(
"/api/vecs/{variant}",

View File

@@ -1,10 +1,10 @@
use axum::{Router, response::Redirect, routing::get};
use crate::api::{explorer::ApiExplorerRoutes, metrics::ApiMetricsRoutes};
use crate::api::{chain::ApiExplorerRoutes, metrics::ApiMetricsRoutes};
use super::AppState;
mod explorer;
mod chain;
mod metrics;
pub trait ApiRoutes {