This makes the Router#route macro generate more efficient code.
We now generate a direct string comparison for mapping the request to the right implementation, instead of a HashMap. An example macro expansion looks like this:
val value = ApiImplFunResponse;
val implRouter = sloth.Router.apply[test.PickleType, test.TypeHelper.ApiResultFun](TypeHelper.functor(SlothSpec.this.executionContext));
val impl = new _root_.sloth.internal.RouterImpl[test.PickleType, test.TypeHelper.ApiResultFun](implRouter);
implRouter.orElse(((endpoint) =>
if (endpoint.traitName.$eq$eq("Api"))
endpoint.methodName match {
case "fun" => Some(((payload: test.PickleType) => impl.execute[scala.Tuple2[Int, String], Int](endpoint, payload)(((args) => value.fun(args._1, args._2)))))
case "multi" => Some(((payload: test.PickleType) => impl.execute[scala.Tuple2[Int, Int], Int](endpoint, payload)(((args) => value.multi(args._1)(args._2)))))
case _ => None
}
else None
))
We are also changing the reoccuring type path: List[String] to Method, which consists of the traitName and the methodName. We have added deprecated aliases for easier migration, it allows to work List[String] (now Method), PathName (now Name), PathNotFound (now MethodNotFound). These will be removed in the upcoming 1.0 release.
This makes the Router#route macro generate more efficient code.
We now generate a direct string comparison for mapping the request to the right implementation, instead of a HashMap. An example macro expansion looks like this:
We are also changing the reoccuring type
path: List[String]
toMethod
, which consists of the traitName and the methodName. We have added deprecated aliases for easier migration, it allows to workList[String]
(nowMethod
),PathName
(nowName
),PathNotFound
(nowMethodNotFound
). These will be removed in the upcoming 1.0 release.