Class DocumentationResource

java.lang.Object
com.reallifedeveloper.common.resource.BaseResource
com.reallifedeveloper.common.resource.documentation.DocumentationResource

public final class DocumentationResource extends BaseResource
A JAX-RS resource that produces HTML documentation from resources on the classpath.
Author:
RealLifeDeveloper
  • Constructor Details

    • DocumentationResource

      public DocumentationResource(String resourceDir, HtmlProducer htmlProducer)
      Creates a new DocumentationResource that reads documents from the specified resource directory, converting them to HTML using the given HtmlProducer.
      Parameters:
      resourceDir - the directory from which to read documents
      htmlProducer - the HtmlProducer to use to convert documents to HTML
      Throws:
      IllegalArgumentException - if any argument is null, of if resourceDir 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 if document was not found