play.api

libs

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
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. class Crypto extends AnyRef

    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

    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]

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

    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

    Utilities for Codecs operations.

  2. object Collections

    Utilities functions for Collections

  3. object Comet

    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

    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

    Helps you format Server-Sent Events

    Helps you format Server-Sent Events

    See also

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

  6. object Files

    FileSystem utilities.

  7. object JNDI

    JNDI Helpers.

  8. object Jsonp extends Serializable

  9. object MimeTypes

    MIME type utilities.

  10. package concurrent

  11. package functional

  12. package iteratee

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

  13. package json

    Json API For example:

    Json API For example:

     case class User(id: Long, name: String, friends: List[User])
    
     implicit object UserFormat extends Format[User] {
      def reads(json: JsValue): User = User(
        (json \ "id").as[Long],
        (json \ "name").as[String],
        (json \ "friends").asOpt[List[User]].getOrElse(List()))
      def writes(u: User): JsValue = JsObject(List(
        "id" -> JsNumber(u.id),
        "name" -> JsString(u.name),
        "friends" -> JsArray(u.friends.map(fr => JsObject(List("id" -> JsNumber(fr.id),
        "name" -> JsString(fr.name)))))))
    }
    
    //then in a controller:
    object MyController extends Controller {
       def displayUserAsJson(id: String) = Action {
          Ok(toJson( User(id.toLong, "myName", friends: List())))
       }
       def saveUser(jsonString: String)= Action {
         val user = play.api.libs.json.Json.parse(jsonString).as[User]
         myDataStore.save(user)
         Ok
       }
    }
  14. package oauth

    OAuth integration helpers.

  15. package openid

  16. package streams

  17. package ws

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

Inherited from AnyRef

Inherited from Any

Ungrouped