34 lines
635 B
Rust
34 lines
635 B
Rust
use {
|
|
hyper::{
|
|
Request,
|
|
StatusCode,
|
|
body::Incoming,
|
|
header::HeaderValue,
|
|
},
|
|
crate::{
|
|
Res,
|
|
DBPool,
|
|
SkyError,
|
|
get_user,
|
|
build_html,
|
|
},
|
|
};
|
|
|
|
|
|
pub async fn user(req: Request<Incoming>, pool: DBPool) -> Res<(String, StatusCode, HeaderValue), SkyError> {
|
|
let uri: &str = req.uri().path().as_ref();
|
|
let login = &uri[2..uri.len()];
|
|
let body: String;
|
|
|
|
let user = get_user(pool, login.to_string()).await;
|
|
if user.is_ok() {
|
|
body = format!("{}", user?.uuid);
|
|
}
|
|
else {
|
|
body = "Not fond :(".to_owned();
|
|
}
|
|
|
|
let restype: HeaderValue = "text/html".parse().unwrap();
|
|
Ok((build_html(&body), StatusCode::OK, restype))
|
|
}
|