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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) protected StringgenerateApiUrl(jakarta.servlet.http.HttpServletRequest request) Generates a URL that the caller can use to access the REST API.protected abstract ObjectgenerateConfig(jakarta.servlet.http.HttpServletRequest request) Called to generate the configuration object.protected abstract StringGets the relative path of the API.protected abstract StringGets the API URL override.protected abstract StringCalled to get the variable name for the output JSONP payload.protected static StringresolveUrlFromXForwarded(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, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
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:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException- See Also:
-
HttpServlet.doGet(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
-
getVarName
Called to get the variable name for the output JSONP payload.- Returns:
- the JSONP variable name
-
generateConfig
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
Generates a URL that the caller can use to access the REST API.- Parameters:
request- the HTTP request- Returns:
- the generated API URL
-
getApiUrlOverride
Gets the API URL override. Returns null if none is configured.- Returns:
- the API URL override
-
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 requestpath- relative path- Returns:
- the resolved URL
-