fix CONFIG == None not working
This commit is contained in:
parent
52a8c48825
commit
1beab57613
1 changed files with 13 additions and 11 deletions
24
src/api.rs
24
src/api.rs
|
@ -7,13 +7,12 @@ use rocket::http::Status;
|
||||||
use rocket::response::status;
|
use rocket::response::status;
|
||||||
use xml::writer::{EmitterConfig, XmlEvent};
|
use xml::writer::{EmitterConfig, XmlEvent};
|
||||||
|
|
||||||
|
|
||||||
/// Holds the config for torznab-toolkit.
|
/// Holds the config for torznab-toolkit.
|
||||||
///
|
///
|
||||||
/// A search function (`/api?t=search`) and capabilities (`/api?t=caps` - `Caps`) are required, everything else is optional.
|
/// A search function (`/api?t=search`) and capabilities (`/api?t=caps` - `Caps`) are required, everything else is optional.
|
||||||
///
|
///
|
||||||
/// <div class="warning">It's required to be set to <i>something</i>, which is why it's an Option set to None.
|
/// <div class="warning">It's required to be set to <i>something</i>, which is why it's an Option set to None.
|
||||||
///
|
///
|
||||||
/// However, this is NOT optional, and attempting to do anything with CONFIG not set will return an `Err`.</div>
|
/// However, this is NOT optional, and attempting to do anything with CONFIG not set will return an `Err`.</div>
|
||||||
pub static mut CONFIG: Option<Config> = None;
|
pub static mut CONFIG: Option<Config> = None;
|
||||||
|
|
||||||
|
@ -23,11 +22,14 @@ pub static mut CONFIG: Option<Config> = None;
|
||||||
#[get("/api?t=caps")]
|
#[get("/api?t=caps")]
|
||||||
pub(crate) fn caps() -> status::Custom<String> {
|
pub(crate) fn caps() -> status::Custom<String> {
|
||||||
unsafe {
|
unsafe {
|
||||||
if CONFIG == None {
|
match CONFIG {
|
||||||
return status::Custom(
|
None => {
|
||||||
Status::InternalServerError,
|
return status::Custom(
|
||||||
"500 Internal server error: Config not specified".to_string(),
|
Status::InternalServerError,
|
||||||
);
|
"500 Internal server error: Config not specified".to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Some(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +123,7 @@ mod tests {
|
||||||
CONFIG = Some(create_config());
|
CONFIG = Some(create_config());
|
||||||
println!("{:?}", CONFIG);
|
println!("{:?}", CONFIG);
|
||||||
}
|
}
|
||||||
caps();
|
println!("{:?}", caps());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -129,6 +131,6 @@ mod tests {
|
||||||
unsafe {
|
unsafe {
|
||||||
println!("{:?}", CONFIG);
|
println!("{:?}", CONFIG);
|
||||||
}
|
}
|
||||||
caps();
|
println!("{:?}", caps());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue