Put all URLs under /api/
This commit is contained in:
parent
714e73aeb1
commit
5fc272054c
@ -231,7 +231,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
let _ = rocket::build()
|
let _ = rocket::build()
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
shared::urls::MOUNT_POINT,
|
||||||
routes![
|
routes![
|
||||||
original,
|
original,
|
||||||
refresh,
|
refresh,
|
||||||
|
|||||||
@ -337,7 +337,7 @@ impl QueryRoot {
|
|||||||
.headers
|
.headers
|
||||||
.get_first_value("date")
|
.get_first_value("date")
|
||||||
.and_then(|d| mailparse::dateparse(&d).ok());
|
.and_then(|d| mailparse::dateparse(&d).ok());
|
||||||
let cid_prefix = format!("/cid/{id}/");
|
let cid_prefix = shared::urls::cid_prefix(None, &id);
|
||||||
let body = match extract_body(&m, &id)? {
|
let body = match extract_body(&m, &id)? {
|
||||||
Body::PlainText(PlainText { text, content_tree }) => {
|
Body::PlainText(PlainText { text, content_tree }) => {
|
||||||
let text = if text.len() > MAX_RAW_MESSAGE_SIZE {
|
let text = if text.len() > MAX_RAW_MESSAGE_SIZE {
|
||||||
|
|||||||
@ -12,3 +12,24 @@ pub struct SearchResult {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct Message {}
|
pub struct Message {}
|
||||||
|
|
||||||
|
pub mod urls {
|
||||||
|
pub const MOUNT_POINT: &'static str = "/api";
|
||||||
|
pub fn cid_prefix(host: Option<&str>, cid: &str) -> String {
|
||||||
|
if let Some(host) = host {
|
||||||
|
format!("//{host}/api/cid/{cid}/")
|
||||||
|
} else {
|
||||||
|
format!("/api/cid/{cid}/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn download_attachment(host: Option<&str>, id: &str, idx: &str, filename: &str) -> String {
|
||||||
|
if let Some(host) = host {
|
||||||
|
format!(
|
||||||
|
"//{host}/api/download/attachment/{}/{}/{}",
|
||||||
|
id, idx, filename
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!("/api/download/attachment/{}/{}/{}", id, idx, filename)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -7,20 +7,7 @@ address = "0.0.0.0"
|
|||||||
port = 6758
|
port = 6758
|
||||||
|
|
||||||
[[proxy]]
|
[[proxy]]
|
||||||
backend = "http://localhost:9345/"
|
backend = "http://localhost:9345/api/"
|
||||||
rewrite= "/api/"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/cid"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/original"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/graphiql"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/graphql"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/download"
|
|
||||||
[[proxy]]
|
|
||||||
backend="http://localhost:9345/view"
|
|
||||||
|
|
||||||
[[hooks]]
|
[[hooks]]
|
||||||
stage = "pre_build"
|
stage = "pre_build"
|
||||||
|
|||||||
@ -51,7 +51,7 @@ where
|
|||||||
{
|
{
|
||||||
use web_sys::RequestMode;
|
use web_sys::RequestMode;
|
||||||
|
|
||||||
Request::post("/graphql/")
|
Request::post("/api/graphql/")
|
||||||
.mode(RequestMode::Cors)
|
.mode(RequestMode::Cors)
|
||||||
.json(&body)?
|
.json(&body)?
|
||||||
.send()
|
.send()
|
||||||
|
|||||||
@ -732,7 +732,7 @@ fn message_render(msg: &ShowThreadQueryThreadMessages, open: bool) -> Node<Msg>
|
|||||||
let default = "UNKNOWN_FILE".to_string();
|
let default = "UNKNOWN_FILE".to_string();
|
||||||
let filename = a.filename.as_ref().unwrap_or(&default);
|
let filename = a.filename.as_ref().unwrap_or(&default);
|
||||||
let host = seed::window().location().host().expect("couldn't get host");
|
let host = seed::window().location().host().expect("couldn't get host");
|
||||||
let url = format!("//{host}/download/attachment/{}/{}/{}", a.id,a.idx, filename);
|
let url = shared::urls::download_attachment(Some(&host), &a.id, &a.idx, filename);
|
||||||
let mut fmtr = Formatter::new();
|
let mut fmtr = Formatter::new();
|
||||||
fmtr.with_separator(" ");
|
fmtr.with_separator(" ");
|
||||||
fmtr.with_scales(Scales::Binary());
|
fmtr.with_scales(Scales::Binary());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user