feat: add base_path to api
Lets you replace /api with whatever you want!
This commit is contained in:
parent
3c5f3fd654
commit
94c4428bb0
3 changed files with 6 additions and 3 deletions
|
@ -6,6 +6,6 @@ use actix_web::web;
|
|||
mod v1;
|
||||
mod versions;
|
||||
|
||||
pub fn web() -> Scope {
|
||||
web::scope("/api").service(v1::web()).service(versions::get)
|
||||
pub fn web(path: &str) -> Scope {
|
||||
web::scope(path.trim_end_matches('/')).service(v1::web()).service(versions::get)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ pub struct CacheDatabase {
|
|||
struct WebBuilder {
|
||||
ip: Option<String>,
|
||||
port: Option<u16>,
|
||||
base_path: Option<String>,
|
||||
frontend_url: Url,
|
||||
_ssl: Option<bool>,
|
||||
}
|
||||
|
@ -85,6 +86,7 @@ impl ConfigBuilder {
|
|||
let web = Web {
|
||||
ip: self.web.ip.unwrap_or(String::from("0.0.0.0")),
|
||||
port: self.web.port.unwrap_or(8080),
|
||||
base_path: self.web.base_path.unwrap_or("".to_string()),
|
||||
frontend_url: self.web.frontend_url,
|
||||
};
|
||||
|
||||
|
@ -146,6 +148,7 @@ pub struct Config {
|
|||
pub struct Web {
|
||||
pub ip: String,
|
||||
pub port: u16,
|
||||
pub base_path: String,
|
||||
pub frontend_url: Url,
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ async fn main() -> Result<(), Error> {
|
|||
App::new()
|
||||
.app_data(web::Data::new(data.clone()))
|
||||
.wrap(cors)
|
||||
.service(api::web())
|
||||
.service(api::web(&data.config.web.base_path))
|
||||
})
|
||||
.bind((web.ip, web.port))?
|
||||
.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue