Mercurial Hosting > luan
changeset 1618:a37ffe2d1b14
fix not_found_handler
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 14 Jun 2021 18:45:17 -0600 |
parents | d88fb2eb15aa |
children | 83caee2ed4ad |
files | src/luan/LuanException.java src/luan/LuanTable.java src/luan/modules/PackageLuan.java src/luan/modules/http/Http.luan src/luan/modules/http/LuanHandler.java src/luan/modules/parsers/LuanToString.java |
diffstat | 6 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/LuanException.java --- a/src/luan/LuanException.java Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/LuanException.java Mon Jun 14 18:45:17 2021 -0600 @@ -51,7 +51,7 @@ if( table==null ) { try { LuanTable Boot = (LuanTable)luan.require("luan:Boot.luan"); - table = (LuanTable)Boot.fn("new_error_table").call(luan,this ); + table = (LuanTable)Boot.fn(luan,"new_error_table").call(luan,this ); for( Object stupid : extra.entrySet() ) { Map.Entry entry = (Map.Entry)stupid; table.put( luan, entry.getKey(), entry.getValue() );
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/LuanTable.java --- a/src/luan/LuanTable.java Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/LuanTable.java Mon Jun 14 18:45:17 2021 -0600 @@ -509,8 +509,8 @@ super.finalize(); } - public LuanFunction fn(String fnName) throws LuanException { - return (LuanFunction)rawGet(fnName); + public LuanFunction fn(Luan luan,String fnName) throws LuanException { + return (LuanFunction)get(luan,fnName); } public static void debug(LuanTable table) {
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/modules/PackageLuan.java --- a/src/luan/modules/PackageLuan.java Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/modules/PackageLuan.java Mon Jun 14 18:45:17 2021 -0600 @@ -104,7 +104,7 @@ } Luan.Security security = Luan.setSecurity(luan,null); try { - return (String)Luan.first(boot.fn("read").call(luan,uri,options)); + return (String)Luan.first(boot.fn(luan,"read").call(luan,uri,options)); } catch(LuanException e) { return null; } finally {
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/modules/http/Http.luan --- a/src/luan/modules/http/Http.luan Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/modules/http/Http.luan Mon Jun 14 18:45:17 2021 -0600 @@ -38,7 +38,7 @@ local Http = {} local mt = {} function mt.__index(tbl,key) - if key=="error_priority" then + if key=="error_priority" or key=="not_found_handler" then return get_local_cloned(tbl,key) elseif key=="request" or key=="response" then return get_local_only(tbl,key) @@ -47,7 +47,7 @@ end end function mt.__new_index(tbl,key,value) - if key=="error_priority" then + if key=="error_priority" or key=="not_found_handler" then set_local_cloned(tbl,key,value) elseif key=="request" or key=="response" then set_local_only(tbl,key,value)
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/modules/http/LuanHandler.java --- a/src/luan/modules/http/LuanHandler.java Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/modules/http/LuanHandler.java Mon Jun 14 18:45:17 2021 -0600 @@ -259,7 +259,7 @@ luan = new Luan(currentLuan); } LuanTable module = (LuanTable)luan.require("luan:http/Http.luan"); - return (Response)module.fn("handle_error").call( luan, request, e.table(luan) ); + return (Response)module.fn(luan,"handle_error").call( luan, request, e.table(luan) ); } private Response serviceLuan(Request request) @@ -279,10 +279,10 @@ fn = (LuanFunction)mod; } LuanTable module = (LuanTable)luan.require("luan:http/Http.luan"); - module.fn("new_request").call(luan,request); - module.fn("new_response").call(luan); + module.fn(luan,"new_request").call(luan,request); + module.fn(luan,"new_response").call(luan); fn.call(luan); - return (Response)module.fn("finish").call(luan); + return (Response)module.fn(luan,"finish").call(luan); } private Response serviceNotFound(Request request) @@ -292,19 +292,19 @@ Luan luan; synchronized(currentLuan) { LuanTable module = (LuanTable)currentLuan.require("luan:http/Http.luan"); - fn = module.fn("not_found_handler"); + fn = module.fn(currentLuan,"not_found_handler"); if( fn == null ) return null; luan = new Luan(currentLuan); } LuanTable module = (LuanTable)luan.require("luan:http/Http.luan"); - module.fn("new_request").call(luan,request); - module.fn("new_response").call(luan); + module.fn(luan,"new_request").call(luan,request); + module.fn(luan,"new_response").call(luan); Object obj = Luan.first(fn.call(luan)); if( !(obj instanceof Boolean) ) throw new LuanException("not_found_handler must return boolean"); boolean handled = (Boolean)obj; - return handled ? (Response)module.fn("finish").call(luan) : null; + return handled ? (Response)module.fn(luan,"finish").call(luan) : null; } }
diff -r d88fb2eb15aa -r a37ffe2d1b14 src/luan/modules/parsers/LuanToString.java --- a/src/luan/modules/parsers/LuanToString.java Sun Jun 13 23:39:09 2021 -0600 +++ b/src/luan/modules/parsers/LuanToString.java Mon Jun 14 18:45:17 2021 -0600 @@ -252,10 +252,10 @@ public static void addNumberTypes(Luan luan,LuanTable env) { try { LuanTable module = (LuanTable)luan.require("luan:Number.luan"); - env.rawPut( "double", module.fn("double") ); - env.rawPut( "float", module.fn("float") ); - env.rawPut( "integer", module.fn("integer") ); - env.rawPut( "long", module.fn("long") ); + env.rawPut( "double", module.fn(luan,"double") ); + env.rawPut( "float", module.fn(luan,"float") ); + env.rawPut( "integer", module.fn(luan,"integer") ); + env.rawPut( "long", module.fn(luan,"long") ); } catch(LuanException e) { throw new LuanRuntimeException(e); }