Class DocumentationResource
java.lang.Object
com.reallifedeveloper.common.resource.BaseResource
com.reallifedeveloper.common.resource.documentation.DocumentationResource
A JAX-RS resource that produces HTML documentation from resources on the classpath.
- Author:
- RealLifeDeveloper
-
Field Summary
Fields inherited from class com.reallifedeveloper.common.resource.BaseResource
API_KEY_HTTP_HEADER, API_KEY_QUERY_PARAMETER, CACHE_1_HOUR, DATE_FORMAT
-
Constructor Summary
ConstructorsConstructorDescriptionDocumentationResource
(String resourceDir, HtmlProducer htmlProducer) Creates a newDocumentationResource
that reads documents from the specified resource directory, converting them to HTML using the givenHtmlProducer
. -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.Response
Reads a default document (index.md or readme.md) from the resource directory and converts it to HTML.jakarta.ws.rs.core.Response
getDocumentation
(String document) Reads a document from the resource directory and converts it to HTML.jakarta.ws.rs.core.Response
redirect()
Redirects the client to the proper documentation URL.Methods inherited from class com.reallifedeveloper.common.resource.BaseResource
commaSeparatedStringToList, handleError, logger, parseDate, parseUrl
-
Constructor Details
-
DocumentationResource
Creates a newDocumentationResource
that reads documents from the specified resource directory, converting them to HTML using the givenHtmlProducer
.- Parameters:
resourceDir
- the directory from which to read documentshtmlProducer
- theHtmlProducer
to use to convert documents to HTML- Throws:
IllegalArgumentException
- if any argument isnull
, of ifresourceDir
does not exist
-
-
Method Details
-
redirect
@GET @Path("/") public jakarta.ws.rs.core.Response redirect()Redirects the client to the proper documentation URL.- Returns:
- a response with a status of 301 (Moved Permanently) and the correct location
-
getDocumentation
@GET @Path("/doc") public jakarta.ws.rs.core.Response getDocumentation()Reads a default document (index.md or readme.md) from the resource directory and converts it to HTML.- Returns:
- a response containing the HTML produced
- Throws:
jakarta.ws.rs.WebApplicationException
- with status 404 if no default document was found
-
getDocumentation
@GET @Path("/doc/{document}") public jakarta.ws.rs.core.Response getDocumentation(@PathParam("document") String document) Reads a document from the resource directory and converts it to HTML.- Parameters:
document
- the document to read- Returns:
- a response containing the HTML produced
- Throws:
jakarta.ws.rs.WebApplicationException
- with status 404 ifdocument
was not found
-