feat: remove dependency on socket.io
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
Keeping stuff commented so we can revisit, currently just need a working version
This commit is contained in:
parent
2fb7e7781f
commit
8ec1610b2e
4 changed files with 16 additions and 21 deletions
|
@ -24,7 +24,6 @@ pub struct RevokeRequest {
|
|||
}
|
||||
|
||||
// TODO: Should maybe be a delete request?
|
||||
#[axum::debug_handler]
|
||||
pub async fn post(
|
||||
State(app_state): State<Arc<AppState>>,
|
||||
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use axum::{
|
||||
Router,
|
||||
routing::{any, delete, get, patch},
|
||||
middleware::from_fn_with_state, routing::{any, delete, get, patch}, Router
|
||||
};
|
||||
//use socketioxide::SocketIo;
|
||||
|
||||
use crate::AppState;
|
||||
use crate::{api::v1::auth::CurrentUser, AppState};
|
||||
|
||||
mod uuid;
|
||||
|
||||
pub fn router() -> Router<Arc<AppState>> {
|
||||
Router::new()
|
||||
pub fn router(app_state: Arc<AppState>) -> Router<Arc<AppState>> {
|
||||
let router_with_auth = Router::new()
|
||||
.route("/{uuid}", get(uuid::get))
|
||||
.route("/{uuid}", delete(uuid::delete))
|
||||
.route("/{uuid}", patch(uuid::patch))
|
||||
.route("/{uuid}/socket", any(uuid::socket::ws))
|
||||
.route("/{uuid}/messages", get(uuid::messages::get))
|
||||
.layer(from_fn_with_state(app_state, CurrentUser::check_auth_layer));
|
||||
|
||||
Router::new()
|
||||
.route("/{uuid}/socket", any(uuid::socket::ws))
|
||||
.merge(router_with_auth)
|
||||
}
|
||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -10,7 +10,6 @@ use diesel_async::pooled_connection::deadpool::Pool;
|
|||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||
use error::Error;
|
||||
use objects::MailClient;
|
||||
use socketioxide::SocketIo;
|
||||
use std::{sync::Arc, time::SystemTime};
|
||||
use tower_http::cors::{AllowOrigin, CorsLayer};
|
||||
|
||||
|
@ -24,7 +23,7 @@ mod config;
|
|||
pub mod error;
|
||||
pub mod objects;
|
||||
pub mod schema;
|
||||
mod socket;
|
||||
//mod socket;
|
||||
pub mod utils;
|
||||
mod wordlist;
|
||||
|
||||
|
@ -53,12 +52,6 @@ pub struct AppState {
|
|||
async fn main() -> Result<(), Error> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
//SimpleLogger::new()
|
||||
// .with_level(log::LevelFilter::Info)
|
||||
// .with_colors(true)
|
||||
// .env()
|
||||
// .init()
|
||||
// .unwrap();
|
||||
let args = Args::parse();
|
||||
|
||||
let config = ConfigBuilder::load(args.config).await?.build();
|
||||
|
@ -158,12 +151,12 @@ async fn main() -> Result<(), Error> {
|
|||
// Allow credentials
|
||||
.allow_credentials(true);
|
||||
|
||||
let (socket_io, io) = SocketIo::builder()
|
||||
/*let (socket_io, io) = SocketIo::builder()
|
||||
.with_state(app_state.clone())
|
||||
.build_layer();
|
||||
|
||||
io.ns("/", socket::on_connect);
|
||||
|
||||
*/
|
||||
// build our application with a route
|
||||
let app = Router::new()
|
||||
// `GET /` goes to `root`
|
||||
|
@ -172,8 +165,8 @@ async fn main() -> Result<(), Error> {
|
|||
app_state.clone(),
|
||||
))
|
||||
.with_state(app_state)
|
||||
.layer(cors)
|
||||
.layer(socket_io);
|
||||
//.layer(socket_io)
|
||||
.layer(cors);
|
||||
|
||||
// run our app with hyper, listening globally on port 3000
|
||||
let listener = tokio::net::TcpListener::bind(web.ip + ":" + &web.port.to_string()).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue