armeria-0.47.0
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 aServiceto aServerBuilderor aVirtualHostBuilder. We do not acceptService<?, ?>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 ofLoggingService::new. -
The type of
RequestContext.method()andRequestLog.method()were changed fromStringtoHttpMethod. -
RequestContext.path()andRequestLog.path()have been split intopath()andquery(). -
RequestContext.fragment()andRequestLog.fragment()are now nullable. -
Revamped
PathMappingto 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
AggregatedHttpMessageinto aDynamicHttpFunctionmethod automatically. -
#567 Handle a
DynamicHttpFunctionmethod whose return type isAggregatdHttpMessage.public class MyAnnotatedHttpService { @Post @Path("/upload") public AggregatedHttpMessage hello(AggregatedHttpMessage uploadRequest) { ... } }