line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.8k stars 912 forks source link

Nested context paths #5758

Open ikhoon opened 3 months ago

ikhoon commented 3 months ago

Currently, a context path is only supported at the root path. Nested context paths will help group and isolate each service.

sb.contextPath("/rest")
      .contextPath("/catalog")
          .service("/product", new GetProductService())
          .service("/products", new ProductsHandler())
          .and()
      .contextPath("/cart")
          .service("/checkout", new CheckoutService());
          ... 
          .and()
      .and()
  .contextPath("/gql")
      .service("/catalog", new GraphQLService());

Discussion: https://discord.com/channels/1087271586832318494/1250406858100047896/1250406882426753036

chickenchickenlove commented 2 months ago

Hello @ikhoon nim. May i look at this issue?

I understood it like this. is my understanding correct?

If we use and() to go back 1-depth before, I think it will cause breakpoints.

From now, and() return Generic <T>. In most case, Generic <T> is ServerBuilder Type. However, contextPath() will returns ContextPathServiceBuilder type. Thus, it will make breaking change.

How about before() or previous() instead of using and() generally to go back 1-depth before? I think, in that way, user will not encounter braking changes.

For Example,

sb.contextPath("/rest")
      .contextPath("/catalog")
          .service("/product", new GetProductService())
          .service("/products", new ProductsHandler())
          .before()
      .contextPath("/cart")
          .contextPath("/foo")
               .contextPath("/bar")
                    .service("/checkout", new CheckoutService());
                    .and()
  .contextPath("/gql")
      .service("/catalog", new GraphQLService());