Routes

zio.http.Routes
See theRoutes companion class

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Show all
Self type
Routes.type

Members list

Type members

Inherited and Abstract types

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def apply[Env, Err](route: Route[Env, Err], routes: Route[Env, Err]*): Routes[Env, Err]
def fromIterable[Env, Err](routes: Iterable[Route[Env, Err]]): Routes[Env, Err]
def serveDirectory(path: Path, docRoot: File)(implicit trace: Trace): Routes[Any, Nothing]

Creates routes for serving static files from the directory docRoot at the url path path.

Creates routes for serving static files from the directory docRoot at the url path path.

Example: Routes.serveDirectory(Path.empty / "assets", new File("/some/local/path"))

With this routes in place, a request to https://www.domain.com/assets/folder/file1.jpg would serve the local file /some/local/path/folder/file1.jpg.

Attributes

def serveResources(path: Path, resourcePrefix: String = ...)(implicit trace: Trace): Routes[Any, Nothing]

Creates routes for serving static files at URL path path from resources with the given resourcePrefix.

Creates routes for serving static files at URL path path from resources with the given resourcePrefix.

Example: Routes.serveResources(Path.empty / "assets", "webapp")

With this routes in place, a request to https://www.domain.com/assets/folder/file1.jpg would serve the file src/main/resources/webapp/folder/file1.jpg. Note how the URL path is removed and the resourcePrefix prepended.

Most build systems support resources in the src/main/resources directory. In the above example, the file src/main/resources/webapp/folder/file1.jpg would be served.

The resourcePrefix defaults to "public". To prevent insecure sharing of resource files, resourcePrefix must start with a / followed by at least 1 valid java identifier character. The / will be prepended if it is not present.

Attributes

def singleton[Env, Err](h: Handler[Env, Err, (Path, Request), Response])(implicit trace: Trace): Routes[Env, Err]

Concrete fields

val empty: Routes[Any, Nothing]

An HTTP application that does not handle any routes.

An HTTP application that does not handle any routes.

Attributes