Package

play.api

libs

Permalink

package libs

Contains various APIs that are useful while developing web applications.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. libs
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. class Crypto extends AnyRef

    Permalink

    Cryptographic utilities.

    Cryptographic utilities.

    These utilities are intended as a convenience, however it is important to read each methods documentation and understand the concepts behind encryption to use this class properly. Safe encryption is hard, and there is no substitute for an adequate understanding of cryptography. These methods will not be suitable for all encryption needs.

    For more information about cryptography, we recommend reading the OWASP Cryptographic Storage Cheatsheet:

    https://www.owasp.org/index.php/Cryptographic_Storage_Cheat_Sheet

    Annotations
    @Singleton()
  2. case class CryptoConfig(secret: String, provider: Option[String] = None, aesTransformation: String = "AES/CTR/NoPadding") extends Product with Serializable

    Permalink

    Configuration for Crypto

    Configuration for Crypto

    secret

    The application secret

    provider

    The crypto provider to use

    aesTransformation

    The AES transformation to use

  3. class CryptoConfigParser extends Provider[CryptoConfig]

    Permalink
    Annotations
    @Singleton()
  4. case class Jsonp(padding: String, json: JsValue) extends Product with Serializable

    Permalink

    JSONP helper.

    JSONP helper.

    Example of use, provided the following route definition:

    GET  /my-service       Application.myService(callback: String)

    The following action definition:

    def myService(callback: String) = Action {
      val json = ...
      Ok(Jsonp(callback, json))
    }

    And the following request:

    GET /my-service?callback=foo

    The response will have content type “text/javascript” and will look like the following:

    foo({...});

    Another example, showing how to serve either JSON or JSONP from the same action, according to the presence of a “callback” parameter in the query string:

    def myService = Action { implicit request =>
      val json = ...
      request.queryString.get("callback").flatMap(_.headOption) match {
        case Some(callback) => Ok(Jsonp(callback, json))
        case None => Ok(json)
      }
    }

Value Members

  1. object Codecs

    Permalink

    Utilities for Codecs operations.

  2. object Collections

    Permalink

    Utilities functions for Collections

  3. object Comet

    Permalink

    Helper function to produce a Comet Enumeratee.

    Helper function to produce a Comet Enumeratee.

    Example:

    val cometStream = Enumerator("A", "B", "C") &> Comet(callback = "console.log")
  4. object Crypto

    Permalink

    Cryptographic utilities.

    Cryptographic utilities.

    These utilities are intended as a convenience, however it is important to read each methods documentation and understand the concepts behind encryption to use this class properly. Safe encryption is hard, and there is no substitute for an adequate understanding of cryptography. These methods will not be suitable for all encryption needs.

    For more information about cryptography, we recommend reading the OWASP Cryptographic Storage Cheatsheet:

    https://www.owasp.org/index.php/Cryptographic_Storage_Cheat_Sheet

  5. object EventSource

    Permalink

    Helps you format Server-Sent Events

    Helps you format Server-Sent Events

    See also

    http://www.w3.org/TR/eventsource/

  6. object Files

    Permalink

    FileSystem utilities.

  7. object JNDI

    Permalink

    JNDI Helpers.

  8. object Jsonp extends Serializable

    Permalink
  9. object MimeTypes

    Permalink

    MIME type utilities.

  10. package concurrent

    Permalink
  11. package functional

    Permalink
  12. package iteratee

    Permalink

    The Iteratee monad provides strict, safe, and functional I/O.

  13. package json

    Permalink

    Json API For example:

    Json API For example:

    import play.api.libs.json._
    import play.api.libs.functional.syntax._
    
    case class User(id: Long, name: String, friends: Seq[User] = Seq.empty)
    object User {
    
      // In this format, an undefined friends property is mapped to an empty list
      implicit val format: Format[User] = (
        (__ \ "id").format[Long] and
        (__ \ "name").format[String] and
        (__ \ "friends").lazyFormatNullable(implicitly[Format[Seq[User]]])
          .inmap[Seq[User]](_ getOrElse Seq.empty, Some(_))
      )(User.apply, unlift(User.unapply))
    }
    
    //then in a controller:
    
    object MyController extends Controller {
       def displayUserAsJson(id: String) = Action {
          Ok(Json.toJson(User(id.toLong, "myName")))
       }
       def saveUser(jsonString: String)= Action {
         val user = Json.parse(jsonString).as[User]
         myDataStore.save(user)
         Ok
       }
    }
  14. package oauth

    Permalink

    OAuth integration helpers.

  15. package openid

    Permalink
  16. package streams

    Permalink
  17. package ws

    Permalink

    Asynchronous API to to query web services, as an http client.

Inherited from AnyRef

Inherited from Any

Ungrouped