46 lines
2.1 KiB
Rust
46 lines
2.1 KiB
Rust
use actix_web::web;
|
|
use actix_session::{SessionMiddleware, storage::CookieSessionStore};
|
|
use actix_web::cookie::Key;
|
|
use crate::controllers::home::HomeController;
|
|
use crate::controllers::auth::AuthController;
|
|
use crate::controllers::ticket::TicketController;
|
|
|
|
/// Configures all application routes
|
|
pub fn configure_routes(cfg: &mut web::ServiceConfig) {
|
|
// Generate a random key for cookie encryption
|
|
let key = Key::generate();
|
|
|
|
// Configure session middleware with cookie store
|
|
let session_middleware = SessionMiddleware::new(
|
|
CookieSessionStore::default(),
|
|
key.clone()
|
|
);
|
|
|
|
|
|
cfg.service(
|
|
web::scope("")
|
|
.wrap(session_middleware)
|
|
// Home routes
|
|
.route("/", web::get().to(HomeController::index))
|
|
.route("/about", web::get().to(HomeController::about))
|
|
.route("/contact", web::get().to(HomeController::contact))
|
|
.route("/contact", web::post().to(HomeController::submit_contact))
|
|
.route("/editor", web::get().to(HomeController::editor))
|
|
|
|
// Auth routes
|
|
.route("/login", web::get().to(AuthController::login_page))
|
|
.route("/login", web::post().to(AuthController::login))
|
|
.route("/register", web::get().to(AuthController::register_page))
|
|
.route("/register", web::post().to(AuthController::register))
|
|
.route("/logout", web::get().to(AuthController::logout))
|
|
|
|
// Ticket routes
|
|
.route("/tickets", web::get().to(TicketController::list_tickets))
|
|
.route("/tickets/new", web::get().to(TicketController::new_ticket))
|
|
.route("/tickets/new", web::post().to(TicketController::create_ticket))
|
|
.route("/tickets/my", web::get().to(TicketController::my_tickets))
|
|
.route("/tickets/{id}", web::get().to(TicketController::show_ticket))
|
|
.route("/tickets/{id}/comment", web::post().to(TicketController::add_comment))
|
|
.route("/tickets/{id}/status/{status}", web::get().to(TicketController::update_status))
|
|
);
|
|
} |