2
0
Nicolas Cannasse 17 жил өмнө
parent
commit
0bbf7535cf
1 өөрчлөгдсөн 11 нэмэгдсэн , 0 устгасан
  1. 11 0
      std/mtwin/web/Handler.hx

+ 11 - 0
std/mtwin/web/Handler.hx

@@ -165,6 +165,17 @@ class Handler<T> {
 		},lock);
 	}
 
+
+	function instance<T>( h : T -> Void, get : Int -> Bool -> T, lock : Bool ) : Void -> Void {
+		var me = this;
+		return function() {
+			var id = Std.parseInt(me.request.getPathInfoPart(me.level+1));
+			var inst = get(id,lock);
+			if( inst == null ) throw ObjectNotFound(id);
+			h(inst);
+		};
+	}
+
 	// action declarators
 
 	function free( n:String, ?t:String, ?cb:Void->Void ){