@@ -907,7 +907,7 @@ struct Worker
907
907
static if (hasUDA! (f, route))
908
908
{
909
909
// If one of the route UDAs returns true, we will launch the function.
910
- bool willLaunchFunc ()
910
+ bool willLaunchFunc ()()
911
911
{
912
912
static foreach (attr; getUDAs! (f, route))
913
913
{
@@ -919,19 +919,40 @@ struct Worker
919
919
920
920
bool willLaunch = willLaunchFunc();
921
921
}
922
- else immutable willLaunch = true ;
922
+ else enum willLaunch = true ;
923
+
924
+ request._internal._route ~= ff.mod ~ " ." ~ ff.name;
923
925
924
926
if (willLaunch)
925
927
{
926
- static if (__traits(compiles, f(request, output))) f(request, output);
927
- else static if (__traits(compiles, f(request))) f(request) ;
928
- else f(output) ;
929
- }
928
+ // Temporarily set the dirty flag to false. It will be restored at the end of the function.
929
+ bool wasDirty = output._internal._dirty ;
930
+ if (wasDirty) output._internal._dirty = false ;
931
+ scope (exit) if (wasDirty) output._internal._dirty = true ;
930
932
931
- request._internal._route ~= ff.mod ~ " ." ~ ff.name;
932
- }
933
+ import std.meta : AliasSeq;
934
+
935
+ // Get the parameters of the function
936
+ static if (__traits(compiles, f(request, output))) auto params = AliasSeq! (request, output);
937
+ else static if (__traits(compiles, f(request))) auto params = AliasSeq! (request);
938
+ else auto params = AliasSeq! (output);
939
+
940
+ // Check if the function has a fallthrough return value
941
+ Fallthrough tmpFt;
942
+ enum withFallthrough = __traits(compiles, tmpFt = f(params));
933
943
934
- if (output._internal._dirty) return true ;
944
+ static if (withFallthrough)
945
+ {
946
+ if (f(params) == Fallthrough.No) return true ;
947
+ }
948
+ else
949
+ {
950
+ f(params);
951
+ if (output._internal._dirty) return true ;
952
+ }
953
+
954
+ }
955
+ }
935
956
}
936
957
937
958
return false ;
0 commit comments