app: Allow to configure the API base url
This commit is contained in:
parent
ecea84d95b
commit
d0313af5ba
1 changed files with 12 additions and 1 deletions
|
|
@ -10,6 +10,17 @@ use crate::sidebar::RegaladeSidebar;
|
||||||
|
|
||||||
mod sidebar;
|
mod sidebar;
|
||||||
|
|
||||||
|
const API_ROUTE: &str = match option_env!("REGALADE_API_SERVER_BASE") {
|
||||||
|
None => "http://localhost:8085",
|
||||||
|
Some(v) => v,
|
||||||
|
};
|
||||||
|
|
||||||
|
macro_rules! api {
|
||||||
|
($($arg:tt)*) => {
|
||||||
|
&format!("{API_ROUTE}/api/{}", format_args!($($arg)*))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Routable, Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Routable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
enum Route {
|
enum Route {
|
||||||
#[at("/")]
|
#[at("/")]
|
||||||
|
|
@ -150,7 +161,7 @@ fn switch(route: Route) -> Html {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_login(username: String, password: String) -> anyhow::Result<()> {
|
async fn do_login(username: String, password: String) -> anyhow::Result<()> {
|
||||||
let rsp = gloo_net::http::Request::post("http://localhost:8085/api/login")
|
let rsp = gloo_net::http::Request::post(api!("login"))
|
||||||
.json(&LoginRequest { username, password })?
|
.json(&LoginRequest { username, password })?
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue