Remove debug prints

This commit is contained in:
Marin Minnerly 2024-01-14 21:35:19 -08:00
parent 8ba4055e13
commit e6a98116a9
4 changed files with 2 additions and 12 deletions

View file

@ -60,7 +60,6 @@ impl FromLua<'_> for RequestConfig {
fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> { fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> {
// If we just got a string we assume its a GET request to a given url // If we just got a string we assume its a GET request to a given url
if let LuaValue::String(s) = value { if let LuaValue::String(s) = value {
println!("{:?}", s);
return Ok(Self { return Ok(Self {
url: s.to_string_lossy().to_string(), url: s.to_string_lossy().to_string(),
method: Method::GET, method: Method::GET,

View file

@ -69,8 +69,6 @@ async fn net_request<'lua>(lua: &'lua Lua, config: RequestConfig) -> LuaResult<L
where where
'lua: 'static, // FIXME: Get rid of static lifetime bound here 'lua: 'static, // FIXME: Get rid of static lifetime bound here
{ {
println!("net_request config {:?}", config);
// Create and send the request // Create and send the request
let client = NetClient::from_registry(lua); let client = NetClient::from_registry(lua);
let mut request = client.request(config.method, &config.url); let mut request = client.request(config.method, &config.url);
@ -140,27 +138,20 @@ async fn net_serve<'lua>(
where where
'lua: 'static, // FIXME: Get rid of static lifetime bound here 'lua: 'static, // FIXME: Get rid of static lifetime bound here
{ {
println!("port {:?}", port);
let sched = lua let sched = lua
.app_data_ref::<&Scheduler>() .app_data_ref::<&Scheduler>()
.expect("Lua struct is missing scheduler"); .expect("Lua struct is missing scheduler");
println!("config {:?}", config);
let address_pattern = Regex::new(r"(?:.*:\/\/)?([\d\.]+)(?::\d+)?").unwrap(); let address_pattern = Regex::new(r"(?:.*:\/\/)?([\d\.]+)(?::\d+)?").unwrap();
let address = match &config.address { let address = match &config.address {
Some(addr) => { Some(addr) => {
let caps = address_pattern.captures(addr.to_str()?).unwrap(); let caps = address_pattern.captures(addr.to_str()?).unwrap();
println!("captures {:?}", &caps);
caps[1].parse::<Ipv4Addr>()? caps[1].parse::<Ipv4Addr>()?
} }
None => Ipv4Addr::new(127, 0, 0, 1), None => Ipv4Addr::new(127, 0, 0, 1),
}; };
println!("address {:?}", address);
let builder = bind_to_addr(address, port)?; let builder = bind_to_addr(address, port)?;
create_server(lua, &sched, config, builder) create_server(lua, &sched, config, builder)

View file

@ -28,8 +28,6 @@ use super::{
pub(super) fn bind_to_addr(address: Ipv4Addr, port: u16) -> LuaResult<Builder<AddrIncoming>> { pub(super) fn bind_to_addr(address: Ipv4Addr, port: u16) -> LuaResult<Builder<AddrIncoming>> {
let addr = SocketAddr::from((address, port)); let addr = SocketAddr::from((address, port));
println!("attempting to bind to {:?}", addr);
match Server::try_bind(&addr) { match Server::try_bind(&addr) {
Ok(b) => Ok(b), Ok(b) => Ok(b),
Err(e) => Err(LuaError::external(format!( Err(e) => Err(LuaError::external(format!(

View file

@ -21,6 +21,8 @@ local thread = task.delay(1, function()
end) end)
local handle = net.serve(PORT, function(request) local handle = net.serve(PORT, function(request)
-- print("Request:", request)
-- print("Responding with", RESPONSE)
assert(request.path == "/some/path") assert(request.path == "/some/path")
assert(request.query.key == "param2") assert(request.query.key == "param2")
assert(request.query.key2 == "param3") assert(request.query.key2 == "param3")