io.pedestal.http.servlet

Generic Servlet adapter that closes over its implementation functions; this dynamically creates a Servlet instance that can be used with a servlet container such as Jetty.

servlet

(servlet & {:keys [init service destroy]})

Returns an instance of jakarta.servlet.Servlet using provided functions for its implementation.

Options:

  • :init optional, initialization function taking two arguments: the Servlet and its ServletConfig
  • :service required, handler function taking three arguments: the Servlet, ServletRequest, and ServletResponse
  • :destroy optional, shutdown function taking one argument: the Servlet

The :init, :service, and :destroy options correspond to the Servlet interface methods of the same names.

The returned servlet instance also implements the ServletConfig interface.

Note: this function returns an instance, not a class. If you need a class with a static name (for example, to deploy to a Servlet container) use the Java class pedestal.servlet.ClojureVarServlet.