diff --git a/src/lune/builtins/net/mod.rs b/src/lune/builtins/net/mod.rs index 552fd55..c06d0f1 100644 --- a/src/lune/builtins/net/mod.rs +++ b/src/lune/builtins/net/mod.rs @@ -35,7 +35,7 @@ pub fn create(lua: &'static Lua) -> LuaResult { let client = NetClientBuilder::new() .headers(&[("User-Agent", create_user_agent_header())])? .build()?; - lua.set_named_registry_value("net.client", client)?; + lua.set_app_data(client); // Create the global table for net TableBuilder::new(lua)? .with_function("jsonEncode", net_json_encode)? @@ -73,7 +73,9 @@ where 'lua: 'static, // FIXME: Get rid of static lifetime bound here { // Create and send the request - let client: LuaUserDataRef = lua.named_registry_value("net.client")?; + let client = lua + .app_data_ref::() + .expect("Missing net client in lua app data"); let mut request = client.request(config.method, &config.url); for (query, value) in config.query { request = request.query(&[(query.to_str()?, value.to_str()?)]);