case class ClasspathResource(path: String) extends Product with Serializable
A resource than can be read from the classpath.
Ok(ClasspathResource("/public/index.html"))
A common use case is to serve static resources (html, js, images files) from the classpath. ClasspathResource values can be directly encoded as Content and used to feed an HTTP response.
Trying to write a missing resource on an HTTP response will close the connection.
Also, this provide a basic security by requiring the path to be asbolutely defined. No directory navigation
is allowed. For example ClasspathResource("/public/../public/index.html")
will resolve to a missing resource.
- Source
- Content.scala
- Alphabetic
- By Inheritance
- ClasspathResource
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ClasspathResource(path: String)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
exists: Boolean
- returns
true is the resource exists in the classpath.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
fold[A](ifMissing: ⇒ A)(f: (ClasspathResource) ⇒ A): A
Returns the result of applying f to this resource if it exists.
Returns the result of applying f to this resource if it exists. Otherwise evaluates the
ifMissing
expression.- ifMissing
the value to be return if the resource is missing.
- f
the function to apply to the resource if it exists.
- returns
a value of type
A
.
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
inputStream: Option[InputStream]
- returns
maybe the
java.io.InputStream
for the resource if it exists in the classpath.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- val path: String
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )