Finished moving to client.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -55,7 +55,7 @@ async fn create_app(state: MoreThanText) -> Router {
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone)]
|
||||
struct SessionID(Uuid);
|
||||
struct SessionID(String);
|
||||
|
||||
impl<S> FromRequestParts<S> for SessionID
|
||||
where
|
||||
@@ -73,9 +73,11 @@ where
|
||||
let requested = req_id.clone();
|
||||
let (tx, mut rx) = channel(1);
|
||||
spawn(async move {
|
||||
tx.send(state.validate_session(requested, None))
|
||||
.await
|
||||
.unwrap();
|
||||
let id = match requested {
|
||||
Some(data) => state.client_with_session(data, None).session_id(),
|
||||
None => state.client().session_id(),
|
||||
};
|
||||
tx.send(id).await.unwrap();
|
||||
});
|
||||
let id = rx.recv().await.unwrap();
|
||||
if !req_id.is_some_and(|x| x == id.to_string()) {
|
||||
@@ -86,7 +88,7 @@ where
|
||||
}
|
||||
|
||||
async fn mtt_conn(
|
||||
_sess_id: SessionID,
|
||||
sess_id: SessionID,
|
||||
method: Method,
|
||||
path: Path<HashMap<String, String>>,
|
||||
state: State<MoreThanText>,
|
||||
@@ -94,6 +96,7 @@ async fn mtt_conn(
|
||||
) -> impl IntoResponse {
|
||||
let (tx, mut rx) = channel(1);
|
||||
spawn(async move {
|
||||
let client = state.client_with_session(sess_id.0, None);
|
||||
match method {
|
||||
Method::GET => match path.get("document") {
|
||||
Some(doc) => tx.send(state.get_document(doc, "home")).await.unwrap(),
|
||||
|
||||
Reference in New Issue
Block a user