Skip to content

armeria-0.35.0

Choose a tag to compare

@trustin trustin released this 20 Jan 02:43
· 4412 commits to main since this release

Highlight: DynamicHttpService

It's much easier to build a non-RPC HTTP service now:

ServerBuilder builder = new ServerBuilder();

// Use annotations (like JAX-RS and Spring Web)
public class MyServiceA extends DynamicHttpService {
    @Get
    @Path("/int/{var}")
    public CompletionStage<Integer> returnInt(@PathParam("var") int var) {
        return CompletableFuture.supplyAsync(() -> var);
    }

    @Get
    @Path("/string/{var}")
    public String returnString(@PathParam("var") String var) {
        return var;
    }
}

builder.serviceUnder("/service/a", new MyServiceA());

// Use builder (like SparkJava)
builder.serviceUnder("/service/b", new DynamicHttpServiceBuilder()
        .addMapping(HttpMethod.GET, "/int/{var}",
                    (ctx, req, args) -> Integer.parseInt(args.get("var")))
        .addMapping(HttpMethod.GET, "/string/{var}",
                    (ctx, req, args) ->args.get("var"))
        .build());

For the complete example, please see HttpServiceTest.java.

Please note that this feature is experimental and thus it has some rough edges and its API may change (in a positive direction) in the future. If you have any feed back on the current API, please let us know!

New features

  • #321 Add DynamicHttpService which implements advanced request mapping
  • #365 #373 Add RequestContext.makeContextAware(CompletionStage) and makeContextAware(CompletableFuture)
  • #369 Add SampledLoggingService

Improvements

Bug fixes

  • #362 WeightedRoundRobinStrategy does not refresh min/max/sumWeight even if endpointGroup returns different endpoints.
  • #363 #371 Graceful shutdown does not respect quiet period correctly.
  • #376 #377 The raw okhttp3.Request object always has 0.0.0.0 authority when armeria-retrofit2 is used.
  • #378 Response is not completed when timeout is disabled dynamically.