ServletModule
presents APIs, which could be used for configuring filters and servlets. Using these expressive APIs known as EDSL, we could configure the mappings between servlets, filters, and respective URLs.
Note
Guice uses an embedded domain specific language or EDSL to help us create bindings simply and readably. We are already using this notation while creating various sort of bindings using the bind()
APIs. Readers could refer to the Binder javadoc, where EDSL is discussed with several examples.
Here, following statement maps the /response
path in the application to the FlightServlet
class's instance:
serve("/response").with(FlightServlet.class);
serve()
returns an instance of ServletKeyBindingBuilder
. It provides various APIs, using which we could map a URL to an instance of servlet. This API also has a variable argument, which helps to avoid repetition. For example, in order to map /response
as well as /response-quick
, both the URLs to FlightServlet.class...