Skip to content

armeria-0.47.0

Choose a tag to compare

@trustin trustin released this 30 May 07:15
· 4255 commits to main since this release

New features

  • (Breaking) #553 Give up trying to be protocol-agnostic and go HTTP-only
    • It is now statically required to add a Service<? super HttpRequest, ? extends HttpResponse> when adding a Service to a ServerBuilder or a VirtualHostBuilder. We do not accept Service<?, ?> anymore.

    • Using a method reference to the one-arg constructor of a decorator service may not work anymore because of Java compiler's type inference failure. For example, you need to use LoggingService.newDecorator() instead of LoggingService::new.

    • The type of RequestContext.method() and RequestLog.method() were changed from String to HttpMethod.

    • RequestContext.path() and RequestLog.path() have been split into path() and query().

    • RequestContext.fragment() and RequestLog.fragment() are now nullable.

    • Revamped PathMapping to support path variables. You can now do the following:

      ServerBuilder sb = ...;
      sb.serviceAt("/hello/:name", new AbstractHttpService() {
          @Override
          protected void doGet(ServiceRequestContext ctx, HttpRequest req, HttpResponseWriter res) {
              final String name = ctx.pathParam("name");
              res.respond(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, "Hello, %s!", name);
          }
      });
      
      sb.service(PathMapping.ofRegex("^/files/(?<filePath>.*)$"), new AbstractHttpService() {
          @Override
          protected void doGet(ServiceRequestContext ctx, HttpRequest req, HttpResponseWriter res) {
              final String filePath = ctx.pathParam("filePath");
              // ... Serve the file ...
          }
      });

Improvements

  • #567 Inject AggregatedHttpMessage into a DynamicHttpFunction method automatically.

  • #567 Handle a DynamicHttpFunction method whose return type is AggregatdHttpMessage.

    public class MyAnnotatedHttpService {
        @Post
        @Path("/upload")
        public AggregatedHttpMessage hello(AggregatedHttpMessage uploadRequest) {
            ...
        }
    }

Bug fixes

  • #565 CatchAllPathMapping.prefix() should return '/'.
  • #571 #572 The CompletableFuture returned by HttpRequest/Response.aggregate() will not complete forever if the stream is aborted, mostly due to timeout.
  • #574 armeria-retrofit2 should respect the encoded annotation parameter.