make config public only to the crate, and make caps() code more readable
This commit is contained in:
parent
007a26974f
commit
12e3ca8402
1 changed files with 6 additions and 9 deletions
15
src/api.rs
15
src/api.rs
|
@ -14,7 +14,7 @@ use xml::writer::{EmitterConfig, XmlEvent};
|
||||||
/// <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(crate) static mut CONFIG: Option<Config> = None;
|
||||||
|
|
||||||
/// Capabilities API endpoint (`/api?t=caps`)
|
/// Capabilities API endpoint (`/api?t=caps`)
|
||||||
// FIXME: VERY incomplete
|
// FIXME: VERY incomplete
|
||||||
|
@ -22,14 +22,11 @@ pub static mut CONFIG: Option<Config> = None;
|
||||||
#[get("/api?t=caps")]
|
#[get("/api?t=caps")]
|
||||||
pub(crate) fn caps() -> status::Custom<RawXml<String>> {
|
pub(crate) fn caps() -> status::Custom<RawXml<String>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
match CONFIG {
|
if CONFIG.is_none() {
|
||||||
None => {
|
return status::Custom(
|
||||||
return status::Custom(
|
Status::InternalServerError,
|
||||||
Status::InternalServerError,
|
RawXml("500 Internal server error: Config not specified".to_string()),
|
||||||
RawXml("500 Internal server error: Config not specified".to_string()),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
Some(_) => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue