karelpeeters
07/04/2017, 7:52 PMtipsy
07/04/2017, 7:59 PMget("/hello") { MyClass::myFunc }
class MyClass {
fun myFunc(ctx: Context) {
ctx.result("Hello World")
}
}
//get signature:
get(String path, Handler handler)
// Handler:
@FunctionalInterface
public interface Handler {
void handle(Context ctx) throws Exception;
}
karelpeeters
07/04/2017, 8:40 PMtipsy
07/04/2017, 9:38 PMilya.gorbunov
07/04/2017, 9:50 PMget("/hello") { MyClass::myFunc }
this way you're passing a lambda which gets the reference and then does nothing.
You should pass the reference itself instead of the lambda:
get("/hello", MyClass::myFunc)
tipsy
07/04/2017, 9:55 PMtipsy
07/04/2017, 9:55 PM