Reputation: 1280
Is there a way of getting ahold of the ByteBuf allocator used in Reactor Netty in a request handler? Similar to how one can do final ByteBufAllocator byteBufAllocator = ctx.alloc();
in pure Netty?
HttpServer.create()
.host("0.0.0.0")
.port(8080)
.route(routes -> {
routes.ws("/ws", (in, out) ->
// how to get the allocator here?
});
})
Upvotes: 0
Views: 275
Reputation: 4544
You can access the ByteBufAllocator
from the WebSocketOutbound
or HttpServerResponse
like this:
HttpServer.create()
.host("0.0.0.0")
.port(8080)
.route(routes -> routes
.ws("/ws", (in, out) -> {
ByteBufAllocator alloc = out.alloc();
// ...
})
.get("/path", (request, response) -> {
ByteBufAllocator alloc = response.alloc();
// ...
})
);
Upvotes: 2