make config public only to the crate, and make caps() code more readable

This commit is contained in:
askiiart 2024-11-26 23:48:13 -06:00
parent 007a26974f
commit 12e3ca8402
Signed by untrusted user who does not match committer: askiiart
GPG key ID: EA85979611654C30

View file

@ -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(_) => {}
} }
} }