Skip to content

Commit e262dac

Browse files
committed
tRPC: change the way the generated class is registered
- fix #3888
1 parent 85cb268 commit e262dac

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

docs/asciidoc/tRPC.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import io.jooby.rpc.trpc.TrpcModule;
1919
2020
public class App extends Jooby {
2121
{
22-
install(new JacksonModule()); // <1>
22+
install(new JacksonModule()); // <1>
2323
24-
install(new TrpcModule()); // <2>
24+
install(new TrpcModule()); // <2>
2525
26-
install(new MovieService_()); // <3>
26+
trpc(new MovieServiceTrpc_()); // <3>
2727
}
2828
}
2929
----
@@ -36,11 +36,11 @@ import io.jooby.json.JacksonModule
3636
import io.jooby.rpc.trpc.TrpcModule
3737
3838
class App : Kooby({
39-
install(JacksonModule()) // <1>
39+
install(JacksonModule()) // <1>
4040
41-
install(TrpcModule()) // <2>
41+
install(TrpcModule()) // <2>
4242
43-
install(MovieService_()) // <3>
43+
trpc(MovieServiceTrpc_()) // <3>
4444
})
4545
----
4646

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,20 @@ public Jooby jsonRpc(@NonNull JsonRpcService service) {
535535
return jsonRpc("/rpc", service);
536536
}
537537

538+
/**
539+
* Registers a tRPC router within the application.
540+
*
541+
* <p>This method provides a native DSL entry point for integrating a tRPC router. It provisions
542+
* the tRPC extension by delegating to the underlying {@link #mvc(Extension)} route registration
543+
* mechanism.
544+
*
545+
* @param trpcRouter The tRPC router extension to register. Must not be null.
546+
* @return A {@link Route.Set} containing the registered tRPC endpoints.
547+
*/
548+
public Route.Set trpc(@NonNull Extension trpcRouter) {
549+
return mvc(trpcRouter);
550+
}
551+
538552
/**
539553
* Add controller routes.
540554
*

tests/src/test/java/io/jooby/i3863/AbstractTrpcProtocolTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class AbstractTrpcProtocolTest {
2727
private void setupApp(Jooby app) {
2828
installJsonEngine(app);
2929
app.install(new TrpcModule());
30-
app.mvc(new MovieServiceTrpc_());
30+
app.trpc(new MovieServiceTrpc_());
3131
}
3232

3333
@ServerTest

0 commit comments

Comments
 (0)