WebSockets and tokio working

This commit is contained in:
2021-06-04 15:22:55 +02:00
parent 1427443caf
commit a96cbdc059
18 changed files with 542 additions and 2007 deletions

View File

@ -0,0 +1,34 @@
use crate::usimp::*;
use crate::database;
use serde_json::{Value, from_value, to_value};
use serde::{Serialize, Deserialize};
use std::ops::Deref;
#[derive(Serialize, Deserialize, Clone)]
struct Input {
name: String,
password: String,
}
#[derive(Serialize, Deserialize, Clone)]
struct Output {
session: String,
token: String,
}
pub async fn handle(input: &InputEnvelope, session: &Session) -> Result<Value, Error> {
Ok(to_value(authenticate(from_value(input.data.clone())?).await?)?)
}
async fn authenticate(input: Input) -> Result<Output, Error> {
match database::client().await? {
database::Client::Postgres(client) => {
client.execute("SELECT * FROM asdf;", &[]).await?;
}
}
Ok(Output {
session: "".to_string(),
token: "".to_string(),
})
}