JEP 408 (Java 18): Simple Web Server with new enhanced request handling

by antonmry
macOS ◆ screen-256color ◆ bash 874 views

“The core functionality of the Simple Web Server is provided by its handler. To support extending this handler for use with existing code, we introduce a new HttpHandlers class with two static methods for handler creation and customization as well as a new method in the Filter class for adapting a request.

handleOrElse complements a conditional handler with another handler, while the factory method of lets you create handlers with pre-set response state. The pre-processing filter obtained from adaptRequest can be used to inspect and adapt certain properties of a request before handling it. Use cases for these methods include delegating exchanges based on the request method, creating a “canned response” handler that always returns a certain response, or adding a header to all incoming requests.”

https://openjdk.java.net/jeps/408