use super::AppState; use crate::{domain::PokemonInfo, error::AppError}; use axum::{ Json, extract::{Path, State}, http::header, response::IntoResponse, }; use serde::Serialize; pub(super) async fn health() -> Json { Json(HealthResponse { status: "ok" }) } pub(super) async fn metrics(State(state): State) -> Result { let body = state.telemetry.render_prometheus()?; Ok(([(header::CONTENT_TYPE, "text/plain; version=0.0.4")], body)) } pub(super) async fn get_pokemon( State(state): State, Path(name): Path, ) -> Result, AppError> { state.service.get_basic(&name).await.map(Json) } pub(super) async fn get_translated_pokemon( State(state): State, Path(name): Path, ) -> Result, AppError> { state.service.get_translated(&name).await.map(Json) } #[derive(Serialize)] pub(super) struct HealthResponse { status: &'static str, }