org.http4s.server.staticcontent

Helpers for serving static content from http4s

Note that these tools are relatively primitive and a dedicated server should be used for serious static content serving.

Attributes

Members list

Type members

Classlikes

trait CacheStrategy[F[_]]

Cache the body of a Response for future use

Cache the body of a Response for future use

A CacheStrategy acts like a after filter in that it can look at the Response and Uri of the Request and decide if the body for the response has already been cached, needs caching, or to let it pass through.

Attributes

Source
CacheStrategy.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class MemoryCache[F]
object FileService

Attributes

Source
FileService.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class MemoryCache[F[_]] extends CacheStrategy[F]

CacheStrategy that will cache all Response bodies in local memory

CacheStrategy that will cache all Response bodies in local memory

This is useful when serving a very limited amount of static content and want to avoid disk access.

Attributes

Companion
object
Source
MemoryCache.scala
Supertypes
trait CacheStrategy[F]
class Object
trait Matchable
class Any
object MemoryCache

Attributes

Companion
class
Source
MemoryCache.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class NoopCacheStrategy[F[_]] extends CacheStrategy[F]

Cache strategy that doesn't cache anything, ever.

Cache strategy that doesn't cache anything, ever.

Attributes

Companion
object
Source
NoopCacheStrategy.scala
Supertypes
trait CacheStrategy[F]
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
NoopCacheStrategy.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Source
ResourceService.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value parameters

basePath

prefix of the path files will be served from

bufferSize

size hint of internal buffers to use when serving resources

cacheStrategy

strategy to use for caching purposes.

classLoader

optional classloader for extracting the resources

pathPrefix

prefix of the Uri that content will be served from

preferGzipped

whether to serve pre-gzipped files (with extension ".gz") if they exist

Attributes

Companion
object
Source
ResourceService.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
ResourceService.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object WebjarService

Attributes

Source
WebjarService.scala
Supertypes
class Object
trait Matchable
class Any
Self type
class WebjarServiceBuilder[F[_]]

Value parameters

cacheStrategy

strategy to use for caching purposes.

classLoader

optional classloader for extracting the resources

preferGzipped

prefer gzip compression format?

webjarAssetFilter

To filter which assets from the webjars should be served

Attributes

Companion
object
Source
WebjarService.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Source
WebjarService.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def fileService[F[_] : Files](config: Config[F]): HttpRoutes[F]

Make a new org.http4s.HttpRoutes that serves static files.

Make a new org.http4s.HttpRoutes that serves static files.

Attributes

Source
package.scala

Make a new org.http4s.HttpRoutes that serves static files, possibly from the classpath.

Make a new org.http4s.HttpRoutes that serves static files, possibly from the classpath.

Attributes

Source
package.scala

Make a new org.http4s.HttpRoutes that serves static files from webjars

Make a new org.http4s.HttpRoutes that serves static files from webjars

Attributes

Source
package.scala

Deprecated methods

def fileService[F[_]](config: Config[F], F: Async[F]): HttpRoutes[F]

Attributes

Deprecated
true
Source
package.scala