Commit 7fb4297
committed
Refactor APT to unify tRPC generation and fully support reactive types
This major refactor unifies the tRPC route generation with the standard
MVC routing flow, eliminating code duplication and properly integrating
tRPC endpoints with Jooby's native reactive pipeline.
Key changes:
* Unify Code Generation: Merged `generateTrpcMethod` into `generateHandlerCall`
in `MvcRoute.java` to use a single, robust parameter extraction and
method invocation flow.
* Reactive Pipeline Support: Fixed an architectural issue where reactive types
(CompletableFuture, Mono, Uni, etc.) were incorrectly wrapped in a synchronous
TrpcResponse. The APT now generates `Publisher<TrpcResponse<T>>`, injecting
the proper `.map(TrpcResponse::of)` operator natively based on the library.
* Hybrid Route Support: `MvcRouter.java` now correctly splits dual-purpose
methods. If a method is annotated with both a standard HTTP method (e.g., `@GET`)
and `@Trpc`, the processor generates two separate mappings and handlers (one
traditional MVC, one strict tRPC).
* tRPC Precedence & Validation: Enforced strict rules for tRPC annotations.
`@Trpc.Query`/`@Trpc.Mutation` take precedence. A bare `@Trpc` annotation
now requires an accompanying `@GET` or `@POST` annotation, otherwise it fails
the build with a descriptive error.
* Kotlin Codegen Fixes: Fixed Return type mismatches for generic parameterized
types (adding `as Type` casts), fixed missing non-null assertions (`!!`),
and ensured `Void`/`Unit` methods correctly emit `TrpcResponse.empty()`.
* Cleanup: Removed dead `trpcPath` resolution methods from `MvcContext`
and `HttpPath`, as well as the obsolete `TrpcMethod` record.1 parent 1a8a492 commit 7fb4297
3 files changed
Lines changed: 38 additions & 13 deletions
File tree
- modules/jooby-apt/src/main/java/io/jooby/internal/apt
- tests/src/test/java/io/jooby/i3863
Lines changed: 27 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
941 | 947 | | |
942 | 948 | | |
943 | 949 | | |
| |||
984 | 990 | | |
985 | 991 | | |
986 | 992 | | |
987 | | - | |
| 993 | + | |
988 | 994 | | |
989 | 995 | | |
990 | 996 | | |
991 | 997 | | |
992 | 998 | | |
993 | | - | |
| 999 | + | |
994 | 1000 | | |
995 | 1001 | | |
996 | 1002 | | |
| |||
1071 | 1077 | | |
1072 | 1078 | | |
1073 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
1074 | 1090 | | |
1075 | 1091 | | |
1076 | 1092 | | |
| |||
1079 | 1095 | | |
1080 | 1096 | | |
1081 | 1097 | | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1090 | 1107 | | |
1091 | 1108 | | |
1092 | 1109 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
70 | 73 | | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
52 | | - | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
0 commit comments