Class StaticSiteService

  • All Implemented Interfaces:

    public class StaticSiteService
    extends com.linecorp.armeria.server.composition.AbstractCompositeService<com.linecorp.armeria.common.HttpRequest,​com.linecorp.armeria.common.HttpResponse>
    A Service which serves a singlepage static site (SPA). All requests to the static path (e.g., "/static/") will be resolved to a file in the classpath, "sw.js", used to register service workers, will also be resolved to itself in the classpath, and all other requests will resolve to "index.html" in the classpath for handling by the SPA.

    The static site will automatically serve precompressed files if they are found, using the conventions specified in HttpFileServiceBuilder.serveCompressedFiles.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static StaticSiteService of​(java.lang.String staticPath, java.lang.String classpathRoot)
      Creates a new StaticSiteService.
      • Methods inherited from class com.linecorp.armeria.server.composition.AbstractCompositeService

        findService, serve, serviceAdded, serviceAt, services
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.linecorp.armeria.server.Service

        as, decorate, decorate, decorate, shouldCachePath
    • Method Detail

      • of

        public static StaticSiteService of​(java.lang.String staticPath,
                                           java.lang.String classpathRoot)
        Creates a new StaticSiteService.
        staticPath - the URL path from which static resources will be served, e.g., "/static".
        classpathRoot - the root directory in the classpath to serve resources from.