pub struct WebService { /* private fields */ }Expand description
Manageable web service with start/stop lifecycle
Use this when you need to programmatically control the server lifecycle, such as in tests or embedded scenarios.
Implementations§
Source§impl WebService
impl WebService
Sourcepub fn new(bamboo_home_dir: PathBuf) -> Self
pub fn new(bamboo_home_dir: PathBuf) -> Self
Create a new WebService instance
§Arguments
bamboo_home_dir- Bamboo home directory (e.g.,${HOME}/.bambooor custom path)
Sourcepub async fn start(&mut self, port: u16) -> Result<(), String>
pub async fn start(&mut self, port: u16) -> Result<(), String>
Start the web service on the specified port using the default localhost bind.
Sourcepub async fn start_with_bind(
&mut self,
port: u16,
bind: &str,
) -> Result<(), String>
pub async fn start_with_bind( &mut self, port: u16, bind: &str, ) -> Result<(), String>
Start the web service on the specified port and bind address.
Sourcepub async fn start_with_bind_tls(
&mut self,
port: u16,
bind: &str,
tls: Option<&TlsConfig>,
) -> Result<(), String>
pub async fn start_with_bind_tls( &mut self, port: u16, bind: &str, tls: Option<&TlsConfig>, ) -> Result<(), String>
Start the web service, terminating TLS itself when tls is Some (#181).
None keeps the plaintext .bind() path unchanged (desktop loopback).
Sourcepub async fn start_with_bind_and_static(
&mut self,
port: u16,
bind: &str,
static_dir: PathBuf,
) -> Result<(), String>
pub async fn start_with_bind_and_static( &mut self, port: u16, bind: &str, static_dir: PathBuf, ) -> Result<(), String>
Start the web service on the specified port and bind address, serving static files alongside the API routes.
Sourcepub async fn start_with_bind_and_static_tls(
&mut self,
port: u16,
bind: &str,
static_dir: PathBuf,
tls: Option<&TlsConfig>,
) -> Result<(), String>
pub async fn start_with_bind_and_static_tls( &mut self, port: u16, bind: &str, static_dir: PathBuf, tls: Option<&TlsConfig>, ) -> Result<(), String>
Like WebService::start_with_bind_and_static, terminating TLS itself
when tls is Some (#181). None keeps the plaintext path unchanged.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the web service is currently running