25 lines
494 B
Rust
25 lines
494 B
Rust
use axum::{
|
|
Json,
|
|
extract::Path,
|
|
http::HeaderMap,
|
|
response::{IntoResponse, Response},
|
|
};
|
|
use uuid::Uuid;
|
|
|
|
use crate::{
|
|
api::CompositeError,
|
|
users::{
|
|
User,
|
|
auth::{UserAuthRequired, UserAuthenticate},
|
|
sessions::Session,
|
|
},
|
|
};
|
|
|
|
pub async fn get_by_id(
|
|
Path(id): Path<Uuid>,
|
|
headers: HeaderMap,
|
|
) -> Result<Response, CompositeError> {
|
|
User::authenticate(&headers)?.required()?;
|
|
Ok(Json(Session::get_by_id(id)?).into_response())
|
|
}
|