Class ShutdownResource

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, BasicUniversalConfig, DefaultConfig, DefaultHtmlConfig

public class ShutdownResource extends BasicRestServlet
Provides the capability to shut down this REST microservice through a REST call.

POST /shutdown stops the process: the "OK" response is sent first, and the exit follows about a second later on a background thread. Shutting down is a write, so it is a POST, never a GET: a safe method passes every CSRF check, so a GET would let any page that embeds <img src=".../shutdown"> stop the process. GET /shutdown is answered with 405.

From the command line, send a non-form content type so a CSRF boundary in front of this resource (see AdminBoundary) admits the request without a token:

curl -X POST -H 'Content-Type: application/json' http://localhost:10000/shutdown

This resource has no authentication of its own. Do not expose it on an untrusted network.

See Also:
  • Constructor Details

  • Method Details

    • shutdown

      public String shutdown()
      [POST /] - Shuts down this microservice.
      Returns:
      The string "OK".