Class ConfigJsServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
io.apicurio.common.apps.web.servlets.ConfigJsServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public abstract class ConfigJsServlet extends jakarta.servlet.http.HttpServlet
Generates the 'config.js' file imported by the UI.
Author:
eric.wittmann@gmail.com
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected String
    generateApiUrl(jakarta.servlet.http.HttpServletRequest request)
    Generates a URL that the caller can use to access the REST API.
    protected abstract Object
    generateConfig(jakarta.servlet.http.HttpServletRequest request)
    Called to generate the configuration object.
    protected abstract String
    Gets the relative path of the API.
    protected abstract String
    Gets the API URL override.
    protected abstract String
    Called to get the variable name for the output JSONP payload.
    protected static String
    resolveUrlFromXForwarded(jakarta.servlet.http.HttpServletRequest request, String path)
    Resolves a URL path relative to the information found in X-Forwarded-Host and X-Forwarded-Proto.

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigJsServlet

      public ConfigJsServlet()
  • Method Details

    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
      See Also:
      • HttpServlet.doGet(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
    • getVarName

      protected abstract String getVarName()
      Called to get the variable name for the output JSONP payload.
      Returns:
      the JSONP variable name
    • generateConfig

      protected abstract Object generateConfig(jakarta.servlet.http.HttpServletRequest request)
      Called to generate the configuration object. This will then be serialized to JSON as the response payload.
      Parameters:
      request - the http request
      Returns:
      generated config
    • generateApiUrl

      protected String generateApiUrl(jakarta.servlet.http.HttpServletRequest request)
      Generates a URL that the caller can use to access the REST API.
      Parameters:
      request - the HTTP request
      Returns:
      the generated API URL
    • getApiUrlOverride

      protected abstract String getApiUrlOverride()
      Gets the API URL override. Returns null if none is configured.
      Returns:
      the API URL override
    • getApiRelativePath

      protected abstract String getApiRelativePath()
      Gets the relative path of the API.
      Returns:
      the relative API path
    • resolveUrlFromXForwarded

      protected static String resolveUrlFromXForwarded(jakarta.servlet.http.HttpServletRequest request, String path)
      Resolves a URL path relative to the information found in X-Forwarded-Host and X-Forwarded-Proto.
      Parameters:
      request - http request
      path - relative path
      Returns:
      the resolved URL