Package com.oorian

Class TextPage


public abstract class TextPage extends HttpFile
Abstract base class for serving plain text HTTP responses.

TextPage provides a simple way to generate text-based HTTP responses such as JSON, XML, CSV, or plain text. Subclasses set the text content via setText(String) and the framework handles output.

Usage:


 @Page(path="/api/status")
 public class StatusPage extends TextPage {
     @Override
     public void build() {
         setContentType("application/json");
         setText("{\"status\": \"OK\"}");
     }
 }
 
Since:
2021
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • TextPage

      public TextPage()
  • Method Details

    • setText

      public void setText(String text)
      Sets the text content to be rendered.
      Parameters:
      text - the text content
    • toString

      protected final void toString(StringBuilder sb)
      Appends the text content to the output buffer.
      Specified by:
      toString in class HttpFile
      Parameters:
      sb - the StringBuilder to append to