forked from pierre/GrammalecteClient
Expose server
This commit is contained in:
parent
7f8a37ce01
commit
757692e054
@ -42,7 +42,7 @@ use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
|
||||
#[cfg(feature = "embedded-server")]
|
||||
mod server;
|
||||
pub mod server;
|
||||
|
||||
/// Spell check options
|
||||
#[derive(Hash, Debug, Eq, PartialEq)]
|
||||
|
@ -12,8 +12,13 @@ pub struct EmbeddedServer {
|
||||
}
|
||||
|
||||
impl EmbeddedServer {
|
||||
/// Start embedded Grammalecte server
|
||||
/// Start embedded Grammalecte server on a random free port
|
||||
pub fn start() -> Result<Self, Box<dyn Error>> {
|
||||
Self::start_listen_on_port(get_free_port()?)
|
||||
}
|
||||
|
||||
/// Start embedded Grammalecte server on a given port
|
||||
pub fn start_listen_on_port(port: u16) -> Result<Self, Box<dyn Error>> {
|
||||
log::info!("Will start server");
|
||||
// First, unpack server
|
||||
let dest = mktemp::Temp::new_dir()?;
|
||||
@ -34,8 +39,6 @@ impl EmbeddedServer {
|
||||
}
|
||||
}
|
||||
|
||||
// Get a free port
|
||||
let port = get_free_port()?;
|
||||
log::info!("Will start to listen on port {}", port);
|
||||
|
||||
let server_file = dest
|
||||
|
Loading…
Reference in New Issue
Block a user