mount scuttlebutt routes

This commit is contained in:
glyph 2021-11-15 11:59:25 +02:00
parent 9756a80094
commit f225cf0dc8
1 changed files with 20 additions and 9 deletions

View File

@ -30,15 +30,15 @@ pub mod routes;
mod tests;
pub mod utils;
use log::{info, error};
use log::{error, info};
use std::process;
use rocket::{catchers, routes, Rocket, Build, fs::FileServer};
use rocket::{catchers, fs::FileServer, routes, Build, Rocket};
use rocket_dyn_templates::Template;
use crate::routes::authentication::*;
use crate::routes::device::*;
use crate::routes::catchers::*;
use crate::routes::device::*;
use crate::routes::index::*;
use crate::routes::ping::*;
use crate::routes::scuttlebutt::*;
@ -47,12 +47,27 @@ use crate::routes::settings::admin::*;
use crate::routes::settings::dns::*;
use crate::routes::settings::network::*;
pub type BoxError = Box<dyn std::error::Error>;
/// Create rocket instance & mount all routes.
fn init_rocket() -> Rocket<Build> {
rocket::build()
.mount(
"/scuttlebutt",
routes![
peers, // WEB ROUTE
friends, // WEB ROUTE
follows, // WEB ROUTE
followers, // WEB ROUTE
blocks, // WEB ROUTE
profile, // WEB ROUTE
private, // WEB ROUTE
follow, // WEB ROUTE
unfollow, // WEB ROUTE
block, // WEB ROUTE
publish, // WEB ROUTE
],
)
.mount(
"/",
routes![
@ -68,13 +83,10 @@ fn init_rocket() -> Rocket<Build> {
login, // WEB ROUTE
login_post, // WEB ROUTE
logout, // WEB ROUTE
messages, // WEB ROUTE
network_home, // WEB ROUTE
network_add_ssid, // WEB ROUTE
network_add_wifi, // WEB ROUTE
network_detail, // WEB ROUTE
peers, // WEB ROUTE
profile, // WEB ROUTE
reboot_cmd, // WEB ROUTE
shutdown_cmd, // WEB ROUTE
shutdown_menu, // WEB ROUTE
@ -130,7 +142,6 @@ fn init_rocket() -> Rocket<Build> {
/// Launch the peach-web rocket server.
#[rocket::main]
async fn main() {
// initialize logger
env_logger::init();
@ -140,7 +151,7 @@ async fn main() {
// launch rocket
info!("Launching Rocket");
if let Err(e) = rocket.launch().await {
if let Err(e) = rocket.launch().await {
error!("Error in Rocket application: {}", e);
process::exit(1);
}