|
@@ -1,6 +1,7 @@
|
|
package hello;
|
|
package hello;
|
|
|
|
|
|
import static io.undertow.util.Headers.CONTENT_TYPE;
|
|
import static io.undertow.util.Headers.CONTENT_TYPE;
|
|
|
|
+import static java.nio.charset.StandardCharsets.US_ASCII;
|
|
import static java.util.Comparator.comparing;
|
|
import static java.util.Comparator.comparing;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -84,9 +85,15 @@ public final class HelloWebServer {
|
|
}
|
|
}
|
|
|
|
|
|
static HttpHandler plaintextHandler() {
|
|
static HttpHandler plaintextHandler() {
|
|
|
|
+ var text = "Hello, World!";
|
|
|
|
+ var bytes = text.getBytes(US_ASCII);
|
|
|
|
+ var buffer = ByteBuffer.allocateDirect(bytes.length)
|
|
|
|
+ .put(bytes)
|
|
|
|
+ .flip();
|
|
|
|
+
|
|
return exchange -> {
|
|
return exchange -> {
|
|
exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain");
|
|
exchange.getResponseHeaders().put(CONTENT_TYPE, "text/plain");
|
|
- exchange.getResponseSender().send("Hello, World!");
|
|
|
|
|
|
+ exchange.getResponseSender().send(buffer.duplicate());
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|