Package io.varhttp

Interface ResponseHeader

All Known Implementing Classes:
VarResponseHeader

public interface ResponseHeader

Carrier for http response headers to be injected into extension point controller methods, to allow the methods to gain access to the response headers

Example:
  @Controller(path = "/myPath")
  public void myControllerMethod(ResponseHeader responseHeader) {
      responseHeader.addHeader("myHeaderName", "myHeaderValue");
      responseHeader.setStatus(200);
  }
 
  • Method Details

    • setStatus

      void setStatus(int httpResponseCode)
      Explicitly set the http response code
      Parameters:
      httpResponseCode - response code, e.g. 200 for "OK"
    • addHeader

      void addHeader(String name, String value)
      Explicitly add a http header to the response
      Parameters:
      name - the header name
      value - the header value
    • setHeader

      void setHeader(String name, String value)
      Explicitly set (override) a http header to the response
      Parameters:
      name - the header name
      value - the header value
    • addCookie

      void addCookie(jakarta.servlet.http.Cookie cookie)
      Explicitly add cookie to the response
      Parameters:
      cookie - the cookie
    • redirect

      void redirect(String path)
      Parameters:
      path - relative to the root of the domain
    • redirectRelative

      void redirectRelative(String path)
      Parameters:
      path - relative to this controller class
    • redirect

      void redirect(URL url)
      Parameters:
      url -
    • setContentType

      void setContentType(String s)