mirror of
https://github.com/v0l/route96.git
synced 2025-06-21 21:26:27 +00:00
fix: add legacy route
This commit is contained in:
@ -18,8 +18,6 @@ use route96::filesystem::FileStore;
|
|||||||
use route96::routes;
|
use route96::routes;
|
||||||
use route96::routes::{get_blob, head_blob, root};
|
use route96::routes::{get_blob, head_blob, root};
|
||||||
use route96::settings::Settings;
|
use route96::settings::Settings;
|
||||||
#[cfg(feature = "void-cat-redirects")]
|
|
||||||
use route96::void_db::VoidCatDb;
|
|
||||||
use route96::webhook::Webhook;
|
use route96::webhook::Webhook;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
@ -78,7 +76,10 @@ async fn main() -> Result<(), Error> {
|
|||||||
)
|
)
|
||||||
.attach(CORS)
|
.attach(CORS)
|
||||||
.attach(Shield::new()) // disable
|
.attach(Shield::new()) // disable
|
||||||
.mount("/", routes![root, get_blob, head_blob])
|
.mount(
|
||||||
|
"/",
|
||||||
|
routes![root, get_blob, head_blob, routes::void_cat_redirect],
|
||||||
|
)
|
||||||
.mount("/admin", routes::admin_routes());
|
.mount("/admin", routes::admin_routes());
|
||||||
|
|
||||||
#[cfg(feature = "analytics")]
|
#[cfg(feature = "analytics")]
|
||||||
@ -95,15 +96,6 @@ async fn main() -> Result<(), Error> {
|
|||||||
{
|
{
|
||||||
rocket = rocket.mount("/", routes::nip96_routes());
|
rocket = rocket.mount("/", routes::nip96_routes());
|
||||||
}
|
}
|
||||||
#[cfg(feature = "void-cat-redirects")]
|
|
||||||
{
|
|
||||||
if let Some(conn) = settings.void_cat_database {
|
|
||||||
let vdb = VoidCatDb::connect(&conn).await?;
|
|
||||||
rocket = rocket
|
|
||||||
.mount("/", routes![routes::void_cat_redirect])
|
|
||||||
.manage(vdb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Err(e) = rocket.launch().await {
|
if let Err(e) = rocket.launch().await {
|
||||||
error!("Rocker error {}", e);
|
error!("Rocker error {}", e);
|
||||||
Err(Error::from(e))
|
Err(Error::from(e))
|
||||||
|
@ -9,7 +9,7 @@ use crate::settings::Settings;
|
|||||||
use crate::void_file::VoidFile;
|
use crate::void_file::VoidFile;
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use http_range_header::{parse_range_header, EndPosition, StartPosition};
|
use http_range_header::{parse_range_header, EndPosition, StartPosition};
|
||||||
use log::warn;
|
use log::{debug, warn};
|
||||||
use nostr::Event;
|
use nostr::Event;
|
||||||
use rocket::fs::NamedFile;
|
use rocket::fs::NamedFile;
|
||||||
use rocket::http::{ContentType, Header, Status};
|
use rocket::http::{ContentType, Header, Status};
|
||||||
@ -365,6 +365,7 @@ pub async fn void_cat_redirect(id: &str, settings: &State<Settings>) -> Option<N
|
|||||||
uuid::Uuid::from_slice_le(nostr::bitcoin::base58::decode(id).unwrap().as_slice())
|
uuid::Uuid::from_slice_le(nostr::bitcoin::base58::decode(id).unwrap().as_slice())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let f = base.join(VoidFile::map_to_path(&uuid));
|
let f = base.join(VoidFile::map_to_path(&uuid));
|
||||||
|
debug!("Legacy file map: {} => {}", id, f.display());
|
||||||
if let Ok(f) = NamedFile::open(f).await {
|
if let Ok(f) = NamedFile::open(f).await {
|
||||||
Some(f)
|
Some(f)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user