143 lines
4.3 KiB
Rust
143 lines
4.3 KiB
Rust
|
use rocket::{catchers, fs::FileServer, routes, Build, Rocket};
|
||
|
use rocket_dyn_templates::Template;
|
||
|
|
||
|
use crate::routes::{
|
||
|
authentication::*,
|
||
|
catchers::*,
|
||
|
index::*,
|
||
|
scuttlebutt::*,
|
||
|
settings::{admin::*, dns::*, menu::*, network::*, scuttlebutt::*},
|
||
|
status::{device::*, network::*},
|
||
|
};
|
||
|
|
||
|
/// Create minimal rocket instance and mount routes. This excludes settings
|
||
|
/// and status routes related to networking and the device (memory,
|
||
|
/// hard disk, CPU etc.).
|
||
|
pub fn build_minimal_rocket() -> Rocket<Build> {
|
||
|
rocket::build()
|
||
|
// GENERAL HTML ROUTES
|
||
|
.mount(
|
||
|
"/",
|
||
|
routes![
|
||
|
help,
|
||
|
home,
|
||
|
login,
|
||
|
login_post,
|
||
|
logout,
|
||
|
reboot_cmd,
|
||
|
shutdown_cmd,
|
||
|
power_menu,
|
||
|
settings_menu,
|
||
|
],
|
||
|
)
|
||
|
// ADMIN SETTINGS HTML ROUTES
|
||
|
.mount(
|
||
|
"/settings/admin",
|
||
|
routes![
|
||
|
admin_menu,
|
||
|
configure_admin,
|
||
|
add_admin,
|
||
|
add_admin_post,
|
||
|
delete_admin_post,
|
||
|
change_password,
|
||
|
change_password_post,
|
||
|
reset_password,
|
||
|
reset_password_post,
|
||
|
forgot_password_page,
|
||
|
send_password_reset_post,
|
||
|
],
|
||
|
)
|
||
|
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
||
|
.mount("/settings/scuttlebutt", routes![ssb_settings_menu])
|
||
|
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
||
|
.mount(
|
||
|
"/scuttlebutt",
|
||
|
routes![
|
||
|
peers, friends, follows, followers, blocks, profile, private, follow, unfollow,
|
||
|
block, publish,
|
||
|
],
|
||
|
)
|
||
|
// STATUS HTML ROUTES
|
||
|
// TODO: replace this with a route for `scuttlebutt_status`
|
||
|
.mount("/status", routes![device_status, network_status])
|
||
|
.mount("/", FileServer::from("static"))
|
||
|
.register("/", catchers![not_found, internal_error, forbidden])
|
||
|
.attach(Template::fairing())
|
||
|
}
|
||
|
|
||
|
/// Create complete rocket instance and mount all routes.
|
||
|
pub fn build_complete_rocket() -> Rocket<Build> {
|
||
|
rocket::build()
|
||
|
// GENERAL HTML ROUTES
|
||
|
.mount(
|
||
|
"/",
|
||
|
routes![
|
||
|
help,
|
||
|
home,
|
||
|
login,
|
||
|
login_post,
|
||
|
logout,
|
||
|
reboot_cmd,
|
||
|
shutdown_cmd,
|
||
|
power_menu,
|
||
|
settings_menu,
|
||
|
],
|
||
|
)
|
||
|
// ADMIN SETTINGS HTML ROUTES
|
||
|
.mount(
|
||
|
"/settings/admin",
|
||
|
routes![
|
||
|
admin_menu,
|
||
|
configure_admin,
|
||
|
add_admin,
|
||
|
add_admin_post,
|
||
|
delete_admin_post,
|
||
|
change_password,
|
||
|
change_password_post,
|
||
|
reset_password,
|
||
|
reset_password_post,
|
||
|
forgot_password_page,
|
||
|
send_password_reset_post,
|
||
|
],
|
||
|
)
|
||
|
// NETWORK SETTINGS HTML ROUTES
|
||
|
.mount(
|
||
|
"/settings/network",
|
||
|
routes![
|
||
|
add_credentials,
|
||
|
connect_wifi,
|
||
|
configure_dns,
|
||
|
configure_dns_post,
|
||
|
disconnect_wifi,
|
||
|
deploy_ap,
|
||
|
deploy_client,
|
||
|
forget_wifi,
|
||
|
network_home,
|
||
|
add_ssid,
|
||
|
add_wifi,
|
||
|
network_detail,
|
||
|
wifi_list,
|
||
|
wifi_password,
|
||
|
wifi_set_password,
|
||
|
wifi_usage,
|
||
|
wifi_usage_alerts,
|
||
|
wifi_usage_reset,
|
||
|
],
|
||
|
)
|
||
|
// SCUTTLEBUTT SETTINGS HTML ROUTES
|
||
|
.mount("/settings/scuttlebutt", routes![ssb_settings_menu])
|
||
|
// SCUTTLEBUTT SOCIAL HTML ROUTES
|
||
|
.mount(
|
||
|
"/scuttlebutt",
|
||
|
routes![
|
||
|
peers, friends, follows, followers, blocks, profile, private, follow, unfollow,
|
||
|
block, publish,
|
||
|
],
|
||
|
)
|
||
|
// STATUS HTML ROUTES
|
||
|
.mount("/status", routes![device_status, network_status])
|
||
|
.mount("/", FileServer::from("static"))
|
||
|
.register("/", catchers![not_found, internal_error, forbidden])
|
||
|
.attach(Template::fairing())
|
||
|
}
|