Class ServerBase

java.lang.Object
no.polaric.core.httpd.ServerBase
Direct Known Subclasses:
Services, WsNotifier

public abstract class ServerBase extends Object
  • Field Details

    • _conf

      protected ServerConfig _conf
    • a

      protected io.javalin.Javalin a
    • _encoding

      public static final String _encoding
      See Also:
    • utcTime

      public static Calendar utcTime
    • localTime

      public static Calendar localTime
    • mapper

      protected static final com.fasterxml.jackson.databind.ObjectMapper mapper
  • Constructor Details

  • Method Details

    • toJson

      public static String toJson(Object obj)
      Serialize object to JSON
    • fromJson

      public static Object fromJson(String text, Class cls)
      Deserialize object from JSON
    • serializeJson

      public static String serializeJson(Object obj)
      Serialize object to JSON
    • deserializeJson

      public static Object deserializeJson(String text, Class cls)
      Deserialize object from JSON
    • addSubtype

      public static void addSubtype(Class type, String name)
      Add a subtype to be used in JSON mapper.
    • icon

      protected String icon()
    • conf

      protected ServerConfig conf()
      Get interface to the server-config
    • wServer

      protected WebServer wServer()
      Get interface to the web-server
    • roundDeg

      protected static double roundDeg(double x)
    • protect

      protected void protect(String prefix, String level)
      Protect an URL. Require login and the given authorization level
    • protect

      protected void protect(String prefix)
      Protect an URL. Require login
    • getAuthInfo

      protected AuthInfo getAuthInfo(io.javalin.http.Context ctx)
      Get info about logged-in user and authorization
      Returns:
      AuthInfo.
    • clientIpAddr

      protected String clientIpAddr(io.javalin.http.Context ctx)
    • systemNotification

      public void systemNotification(String user, String txt, int ttl)
      Send a system notification to a user. TTL is in minutes
    • fixText

      protected String fixText(String t)
      Sanitize text that can be used in HTML output.
    • cleanPath

      public static String cleanPath(String txt)
    • metaTag

      protected String metaTag(String name, String val)